From: <bjo...@it...> - 2003-08-07 17:02:03
|
For synchronization with some relational authorative datastore, I have to search the ldap-server now and then (from cron). From the same computer, to the same ldap-server, with no load (not production yet) I get very different use of time. ldapsearch (from openldap's ldapsearch.c): $time ldapsearch -h ldap -x -b "ou=3Dusers,dc=3Dntnu,dc=3Dno" \ "objectClass=3DposixAccount" uid > /dev/null=20 # numResponses: 26876 # numEntries: 26875 real 0m14.560s user 0m3.390s sys 0m0.820s python-ldap: # start-script import ldap l =3D ldap.open("ldap") l.simple_bind_s("","") res =3D l.search_s("ou=3Dusers,dc=3Dexample,dc=3Dcom",ldap.SCOPE_SUBTREE,= "objectClass=3DposixAccount",["uid"]) print len(res), ' records returned' l.unbind() # end script $ time python ldap-test.py 26875 records returned real 1m6.524s user 0m59.580s sys 0m1.640s second run with python-ldap: real 0m58.190s user 0m52.390s sys 0m1.620s Why the big difference? Running truss and strace on the searches, I find that ldapsearch fetch all entries in one retrieve, while python-ldap fetch one entry by one.=20 ldapsearch is behaving the same way as pythonldap if I add e.g. '-S uid'=20 (sort by uid) In python-ldap: LDAPObject.c: line 684 in function: l_ldap_result( LDAPObject* self, PyObject *args ) int all =3D 1; ^^^^^^^^ does this actually mean anything, and if so - what? Any suggestions on how to fix LDAPObject.c to fetch the result all in one chunk? Or am I looking in the wrong file or something? -- Regards Bj=F8rn Ove Gr=F8tan |