directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject RE: Is it faster/better to include one objectclass or all in query?
Date Wed, 14 Mar 2012 15:18:10 GMT
Emmanuel, thank you.  One follow-up and I should have included this in the original message.
 My query includes an OU as the base dn in the search. 
All entries in this OU all have the same 4 objectclass values. No other objectclass types
are in this particular OU. 
Say I had 1000 entries. Each count for top, person, organizationalPerson and inetOrgperson
would all yield 1000 hits. In this case, should I include the objectclass in the query at
My other search attribute is indexed.  Thanks again for the excellent information!

Carlo Accorsi

-----Original Message-----
From: Emmanuel Lécharny [] 
Sent: Wednesday, March 14, 2012 11:03 AM
Subject: Re: Is it faster/better to include one objectclass or all in query?

Le 3/14/12 3:51 PM, a écrit :
> Hi, when searching for a user having this objectclass hierarchy
> top
>   |_person
>           |_organizationalPerson
>                      |_inetOrgPerson
> and uid = 'jsmith'
> Which query would be less expensive or better/faster?  Thanks!
> (&
>     (objectclass=inetOrgPerson)
>     (uid=jsmith)
> )
> OR
> (&
>                  (&(objectclass=top)
>                  (objectclass=person)
> (objectclass= organizationalPerson)
> (objectclass=inetOrgPerson))
> (uid=jsmith)
> )
It depends on the number of entries selected by each of the filters. The way the filtering
works - for an AND operation at least - is that we first evaluate the number of elements returned
by each single filter, then we pick the smallest one and we process the search using this

For instance, in your case, we will have :

(objectclass=top) ->  matches all the entries (obviously)
(objectclass=person) ->  matches 1000 entries (objectclass= organizationalPerson) ->
 matches 100 entries (less than for the previous filter because organizationalPerson has person
as a superior)
(objectclass=inetOrgPerson) ->  matches 10 entries (same raisonning than upper)

  - if (uid=jsmith) matches 55 entries, then we will use the (objectclass=inetOrgPerson) filter
  - if (uid=jsmith) matches 7 entries, then we will use this filter

at the end, we will browse 10 or 7 entries, depending on the number of matched entries considering
the filter.

If we take your first filter
it's even simpler, as we don't have to evaluate the hierarchy of ObjectClasses.

End of the day : no need to pile up the atomic filters in your request, just use those that
are the most discriminant.

Last, not least, the 'cost' difference will be minimal anyway, as the evaluation is a pretty
fast operation compared to pulling entries from the backend to return them. You will see no

The best thing to do is to have the correct index set depending on the requests you will submit.

Emmanuel Lécharny

View raw message