Unless you have an extremely large database, getting extremely fast queries out of OpenLDAP is pretty straight forward. There are two things one must account for: memory cache and indexing.
Here is the relevent section of from my slapd.conf:
The size of dbcachesize should be big enough to hold your largest index file (*.dbb). dbcachesize speeds up the creation of indexes when adding or modifying entries. The original University of Michigan slapd documentation (which OpenLDAP is based on) implies that dbcachesize should be turned off when you are not loading data into the server in order to save memory. Memory is cheap, so I leave mine on.
The LDBM database spends much of its time reading entries from the id2entry file. If cachesize is large enough to hold the entires in id2entry, performance will increase significantly. Again, memory is cheap so I set this cache value high.
If your directory is strongly biased towards reads rather than writes, you may
want to index most attributes:
If write performance is critical, you can index only the most commonly search
attributes. For example:
Important Note: You must configure your index before you load your data into the LDAP server! If you would like to reindex your databases after your data is loaded: 1) shutdown the ldap server, 2) backup your databases (you always do that, don't you? :-), 3) run lbmcat id2entry.dbb > backup.ldif, 4) make your index changes in slapd.conf, 5) run ldif2ldbm -i backup.ldif, and then 6) restart the ldap server.