[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldap filter order



DT Piotr Wadas wrote:

Hello,
I have

10 000 objects with attributeA=john

and

100 of these objects has also attributeB=mary

both attributes are indexed.

Does it make any difference between

(&(attributeA=john)(attributeB=mary))

vs.

(&(attributeB=mary)(attributeA=john))

I bet it is better to exclude john-matched objects
from the set of 100 mary-matched objects, than
exclude 100 mary-matched objects from the set
of 10 000 john-matched objects, is that right?

Yes, but internally, when we perform an AND on two sets, we re-order them as needed, so it doesn't matter which one was larger coming in. It would be pretty stupid not to.

In other words - does it make sens to order complicated
filters to match possible low-volume results from the left,
and high-volume sets on the right?
This, of course, apply to AND filters only.

The only time you'll see any big benefit to ordering is if one of your terms yields an empty set. In that case, the evaluation can be terminated early without invoking any AND processing at all.

--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/