use the unique flag on ldb attributes to optimise & clauses
authorAndrew Tridgell <tridge@samba.org>
Mon, 1 Jun 2009 12:03:20 +0000 (22:03 +1000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 1 Jun 2009 12:03:20 +0000 (22:03 +1000)
commit73c8566d957af8c823a48912b66aae71b002259b
treee97cbb3a12dc703cc20091c592e7c8122544aa8b
parenta0edb50552090341760c9dfcf27a71df8100e1a5
use the unique flag on ldb attributes to optimise & clauses

When a attribute is marked unique we know that if we find a match
it will be the only possible match. This means that in a list of
subtrees connected by an &, it is best to first load the index values
for the unique entries, as if they find something then we know we
won't have to look any further.

This helps with searches like this:

  (&(objectclass=user)(samaccountname=tridge))

the old code would first have loaded the very large index for the
objectclass=user attribute, and then loaded the single entry for
samaccountname=tridge. Now we load the samaccountname=tridge entry
first, notice that it gives us a single result, and stop, thereby
skipping the load of the objectclass=user index record completely.
source4/lib/ldb/ldb_tdb/ldb_index.c