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

Re: Could ldap do max-like or count-like operation as SQL?



Yuqing Tang wrote:
> 
> >On Wed, Jun 21, 2000 at 10:17:29AM +0800, Yuqing Tang wrote:
> >> >On Tue, Jun 20, 2000 at 07:31:24PM +0800, Yuqing Tang wrote:
> >> >> As our project go on, we store lots of data into ldap, now we should
> >> >> do some statistics on these data, such as who is the oldest or even
> >> >> who is the oldest 1000 or how many people live in CA. Could ldap do
> >> >> that?
> >> >
> >> >LDAP search ...
> >> How to search? Should I search all the entries that satisfied some filter,
> >> and iterator through them to find the max or to count them?
> >>
> >> I am new to this maillist, actually I am writing a client program to do that,
> >> should I fwd my questiong to another maillist?
> >
> >RTFM.
> >
> >ldapsearch '(age=*)' age | perl -e '$/ = "\n\n"; while( <> ) {/^uid=(\w+).*$/m; $u = $1; /^age=(.*)$/m; $p = $1; print "$p $u\n";}' | sort -n | head -1000 > top-1000-ages.txt
> So if I had 1000000 entries in ldap, I must fisrt get all of them to the client,
> then iterate through them to do some statistics? Will the performance be very very
> low?
> 
> In another word, do I use ldap in a wrong way?
> >

  You don't have much choice if your LDAP server only supports version 2 of the LDAP protocol. If it supports version 3 (including support for server controls), you may be able to ask the server to sort the results and to provide you with an arbitrary window into the sorted results (e.g. the oldest 1 or the oldest 1000 person entries). With the Netscape/iPlanet Directory Server that is done with the Virtual List View (VLV) control.

  The other query - how many people live in California - could be answered by searching for all person entries having a particular attribute with the value "California" and counting the returned results. Or if you have a server that supports VLV, you can very quickly get the count without having all the entries returned.

Rob


> >-d
> >
> >--
> >come.to/dannyman
> >
> >.