recently I've noticed something related to indexes and I'm not able to classify is it a
problem or misunderstanding how Indexes are working. Here is scenario:
I'm running OpenLDAP 2.1.30, I have populated database with 25 entries and have index for sn attribute.
Only 3 entries in my database have attribute sn.
I run ldapsearch with the different filters and noticed the following ( SLAPD is in Debug mode).
a) Filter: sn=*
LDAP read only 3 candidates:
<= bdb_index_read 3 candidates
b) Filter: sn=r*.
In this case LDAP reads all entries (25 entries in DB) in order to find a match.
The question is: why in case b) LDAP reads all records. Shouldn't it scan (as it was in the case (a)) only 3 entries.
Is this a bug or misunderstanding how indexes are working in OpenLDAP?
Below is the extract from slapd.conf file:
index objectClass eq
index cn,sn,uid pres,eq,sub