Indexes are noticeable as soon your load rises above some users and can really improve the overall performance of the system. Monitoring query times is fundamental to provide a successful service and avoid future problems from appearing.
We use Samba AD Server in Zentyal Cloud as Active Directory replacement, so it holds user accounts and mailboxes info. It’s also helpful to perform seamlessly migrations from existing systems.
When the number of hosted mailboxes is high, it is important to keep all your query times to a minimum, as every time a mail hits the system (both inbound and outbound mail), some queries are run against Samba (LDAP) in order to resolve its destination. For the case of Zentyal, we support virtual domains, mail alias, and mail forwarding configuration directly from LDAP.
In this post I will go through the process of checking and adding new indexes to the database. Depending on the scenario that could reduce query times by 50x!
Checking indexed attributes
Samba stores LDAP entries using its own database engine (LDB). Indexes support is fairly simple, at the moment only exact attribute indexing and one level indexing are available. Attribute indexing allows to index entries by attribute value and one level indexing allows to index child entries for faster access.
Adding a new index
For the case of Samba AD we are editing a schema based database. Take into account that directly editing @INDEXLIST will not work, as @INDEXLIST is generated from the schema. We will need to edit the schema to ensure indexing on the desired attributes:
First find the base DN for your setup:
And then edit the schema, using ldbedit
and set searchFlags
attribute to 1 on the attribute entry you want to index:
That’s all! You can check again all your indexes and see your attribute is now there, query times should have been improved significantly.