8.4. Checking Indexes For a Search

When searching, you can improve performance by making sure your search is indexed as you expect. One way of checking is to request the debugsearchindex attribute in your results.

$ ldapsearch
 --port 1389
 --baseDN dc=example,dc=com
 "(uid=bjensen)"
 debugsearchindex
dn: cn=debugsearch
debugsearchindex: filter=(uid=bjensen)[INDEX:uid.equality][COUNT:1]
 final=[COUNT:1]

When you request the debugsearchindex attribute, instead of performing the search, OpenDJ returns debug information indicating how it would process the search operation. In the example above you notice OpenDJ hits the equality index for uid right away.

A less exact search requires more work from OpenDJ. In the following example OpenDJ would have to return 160 entries.

$ ldapsearch
 --port 1389
 --baseDN dc=example,dc=com
 "(uid=*)"
 debugsearchindex
dn: cn=debugsearch
debugsearchindex: filter=(uid=*)[NOT-INDEXED] scope=wholeSubtree[COUNT:160]
 final=[COUNT:160]

By default OpenDJ rejects unindexed searches when the number of candidate entries goes beyond the search or look-though limit.