Strange behavior of ldap_result - can someone explain?

Nils Andreas Thommesen (Nils.Thommesen@maxware.no)
Wed, 18 Sep 1996 12:01:48 +0200

I have made an LDAP-application that was not very effective on the "list"
operation. I thought this was partly due to the way LDAP uses search to
accomplish list, instead of having a separate list operation. I was
wrong!

I made the query asynchronous, then polled with regular intervals to sse
if all results were in, using ldap_result, with zero-time waiting, and
asking for all results (not one at a time). The interval with which I am
calling ldap_result has much more importance than what seems logically to
me!

Let me explain: I first tried to poll every second (1000 ms interval).
For a given (uncached) directory list operation my app had to poll 20
times to get all results back! That is 20 -twenty- long seconds, and that
is even on a fast server on the local ethernet! It was terrible!

I could not poll continually, since this application runs under Windows
3.x, and I have "to be nice to the other programs running" (What a OS,
eh?) Therefore, I experimented by decreasing the polling interval. Here
is what I found, using the same uncached directory every time:

Milliseconds No. of calls to ldap_result Total "polling"-time
--------------------------------------------------------------
1000 20 20 seconds!
100 25 2,5 sec
50 21 1,05 sec
10 21 0,21 sec !

This was to a local server, listing members in an organization with more
than 20 entries which caused an LDAP_SIZELIMIT_EXCEEDED, and only 20 were
returned.

Here are the results from quering to other servers, both remote:
(the data are the numbers of calls to ldap_result before everything was
returned)

Ms. wait Server 1 Server 2
---------------------------------------------------------
1000 8 (8 sec) 20 (20 sec)
100 8 (0,8 sec) 22 (2,2 sec)
10 11 (0,11 sec) 74 (0,74 sec)

At server 1, there only 8 entries in the organization I "listed", at
server 2 there where more than 20, but only 20 were returned (size
limit).

So, even though a server might give my application the result in less
than 1/4 seconds, I still have to call ldap_result at least as many times
as there are entries to be returned, meaning if I call it every second,
the operation will take <no of entries> seconds!!! Why is it so?

This is what the man page for ldap_result says:
> A search response is made up of zero or more search entries followed by
> a search result. If all is set to 0, search entries will be returned
> one at a time as they come in, via separate calls to ldap_result(). If
> it's set to 1, the search response will only be returned in its
> entirety, i.e., after all entries and the final search result have been
> received.

I have been using "1" for the "all" parameter in all the results above.
If I use "0", I would have expected similar results, but not when "1" is
used!

Nils Andreas Thommesen -- Nils.Thommesen@maxware.no
- - - - - - - - - - - - - - - - - - - - - -
Work: Maxware, Pirsenteret, N-7005 Trondheim; +47 73 545 722
Home: Klostergata 37 B,7030 Trondheim,Norway; +47 73 52 97 24
Fax : +47 73 545 750
WWW : http://www.kvatro.no/~nat http://www.maxware.no/
- - - - - - - - - - - - - - - - - - - - - -
I'm left-handed, left-eyed, left-footed but not left behind!