pythonldapldap-querypython-ldap

LDAP search takes too long


I'm trying to get more than 50.000 records from LDAP (with python-ldap and page control tools).

I have searching filter, which is

(|(field=value_1) (field=value_2)...(field=value_50000)

But this request taking more than 15 minutes. I'm taking 10 attributes from LDAP for these records.

Could you please tell me if is it okay for some large request or I can try to change filter?


Solution

  • You should refine your search base, and make it the closet possible to what you are searching for, for example, instead of querying dc=company,dc=com use ou=people,dc=company,dc=com.

    You can also build an index of the field you are searching for, and you can also enable cache for your ldap, and finnally concerning your search filter, if you query the same attribute you can try something like:

    &"(field>=MinValue)(field=<MaxValue)"

    It's way better the matching every single attribute.