Managing Indexes
he directory server uses index files to aid in searching the directory. Directory server indexes greatly improve the performance of searches in the directory databases, but they do so at the cost of potentially slower database modification and creation operations. Indexes will also cost more in terms of system resources, especially in disk-space use.
This chapter discusses these index files, how the directory server uses them, and how you manage them. The following topics are covered in this section:
The Searching Algorithm
The general process for how searching is performed in the directory server is as follows:- Size Limit in Entries (see page 319 for a description of this parameter)
- Time Limit in Seconds (see page 319 for a description of this parameter)
- Look Through Limit in Entries (see page 321 for a description of this parameter)
Note
The client may further restrict the number of returned entries by specifying
lower values for the Size Limit in Entries and the Time Limit in Seconds
parameters on the search request.
Types of Indexes
To improve searching efficiency, the directory server maintains five distinct types of indexes:
Note
Indexes are contained in files whose names are based on the indexed attribute,
not the type of index contained in the file. In fact, each index file may contain
multiple types of indexes if multiple indexes are maintained for the specific
attribute. For example, all the indexes maintained for the common name
attribute are contained in the
cn.dbb file.
The Presence Index
The presence (pres) index is the simplest of the indexes. It lets you efficiently search the directory for entries that contain a specific attribute. This is useful if, for example, you want to examine any entries that have access control information associated with them. Generating a aci.dbb file that includes a presence index lets you efficiently perform the search for ACI=*.
The Equality Index
The equality (eq) index allows you to efficiently search for entries containing a specific attribute value. For example, an equality index on the cn attribute allows a user to efficiently perform the search for cn=Babs Jensen.
The Approximate Index
The approximate (approx) index allows efficient approximate or "sounds-like" searches. For example, an entry may include the attribute value cn=Robert E Lee. An approximate search would allow a return for searches against cn~=Robert Lee, cn~=Robert, or cn~=Lee. Similarly, a search against l~=San Fransico (note the misspelling) would return entries including l=San Francisco.
The directory server uses a variation of the metaphone phonetic algorithm to perform this type of searching. Each value is treated as a sequence of words, and a phonetic code is generated for each word.
Values entered on an approximate search are similarly translated into a sequence of phonetic codes. An entry is considered to match a query if:
- all of the query string codes are present in the codes generated in the entry string
- all of the query string codes are specified in the same order as the entry string codes
The Substring Index
The substring (sub) index is a costly index to maintain, but it allows for efficient searching against substrings within entries.
For example, searches of the form
cn=*dersonwould match the common names containing strings such as
Bill Andersonand so forth. Similarly, the search for
Jill Anderson
Steve Sanderson
telephonenumber= *555*would return all the entries in your directory with telephone numbers that contain 555.
-
Note
-
Substring indexes are limited to a minimum of two characters for each entry.
The International Index
The international ("") index speeds up searches for information in international directories. The process for creating an international index is similar to the process for creating regular indexes, except that you associate a collation order with the attributes to be indexed. For a listing of supported locales and their associated OIDs, see Table D.1 on page 500.For more information on creating an international index, see "Creating International Index Entries" on page 165.
The Cost of Indexing
Although indexes greatly improve the speed of searches within the directory server database, you should be aware of the costs related to indexing:
Slower Database Modification and Creation Times
The more indexes you maintain, the longer it takes the directory server to update the database. This is especially true for substring indexes that cause the directory server to generate multiple index file entries every time an attribute value is created or changed. Remember that for substring indexes, the number of index entries created is proportional to the length of the string being indexed. Consider the procedure for creating a specific attribute:For example, suppose the directory server is asked to add the entry:
dn: cn=Bill Pumice, ou=People, o=airius.comFurther suppose that the directory server is maintaining:
objectclass: top
objectClass: person
objectClass: orgperson
objectClass: inetorgperson
cn: Bill Pumice
cn: Bill
sn: Pumice
ou: Manufacturing
ou: people
telephonenumber: 408 555 8834
description: Manufacturing lead for the Z238 line.
- equality, approximate, and substring indexes for common name and surname attributes.
- equality and substring indexes for the telephone number attribute.
- substring indexes for the description attribute.
- Create the common name equality index entry for "Bill" and "Bill Pumice".
- Create the appropriate common name approximate index entries for "Bill" and "Bill Pumice".
- Create the appropriate common name substring index entries for "Bill" and "Bill Pumice".
- Create the surname equality index entry for "Pumice".
- Create the appropriate surname approximate index entry for "Pumice".
- Create the appropriate surname substring index entries for "Pumice".
- Create the telephonenumber equality index entry for "408 555 8834".
- Create the appropriate telephonenumber substring index entries for "408 555 8834".
Higher System Resource Use
One other cost to maintaining index files is the increased system resources they require. Although the impact to your system depends on how large a database you are using and how many attributes exist within your database, consider that:
- Index files use disk space. The more attributes you index, the more files will be created. Also, creating approximate and substring indexes for attributes that contain long and complex strings can cause these files to quickly grow large.
- Index files use memory. To run more efficiently, the directory server tries to place as many index files in memory as possible. You can control the amount of memory allowed per open index file using the "Maximum DB Cache size in Bytes" parameter (refer to page 346 for details on this parameter). Even so, a large number of index files will require more memory.
- Managing index files uses CPU cycles. Although index files will save you CPU cycles during searches, maintaining indexes that are not frequently used can actually waste CPU cycles because of the need to create and manage unnecessary indexes. This is especially true for substring and approximate indexes that require the parsing of long, complex strings.
Creating Indexes
You create indexes for specific attributes by using the "Attribute to be Indexed" parameter (for details on this parameter, refer to page 347). Before you create new indexes, balance the benefits of maintaining indexes against the cost of indexing as described in "The Cost of Indexing" on page 156. Consider that:
- Approximate indexes make little sense for attributes commonly containing numbers, such as telephone numbers.
- Substring indexes make no sense for attributes that do not contain readable strings, such as attributes intended to contain a photograph or password attributes that contain encrypted data.
- Maintaining indexes for attributes that will not be commonly used in a search will increase overhead without improving searching performance.
- Attributes that are not indexed can still be specified in search filters, although the search performance may be degraded significantly, depending on the type of search.
Default Indexes
By default, the directory server automatically manages some indexes. These indexes are intended to improve directory server performance:- Presence index for the ACI attribute. This allows the directory server to quickly obtain the access control information maintained in the database.
- Presence, equality, and substring indexes for the following attributes:
cn, sn, mail, telephoneNumber These indexes are added by default to improve the performance of the most common types of user directory searches.
- Presence, equality, and substring searches for the
ntUserDomainIdattribute. This improves NT Synchronization Service performance. Note that this index has no impact on your directory server's performance if you are not using the NT Synchronization Service. - Equality index for the
uid,uniquemember, andmemberattributes. This is primarily used to improve SuiteSpot performance. - Equality index for the
changenumberattribute. This is primarily used to improve replication performance.
Standard Index Files
Because of the need to maintain default indexes and other internal indexing mechanisms, the directory server maintains several standard index files. They are:
id2entry.dbb--contains the actual directory database entries. All other database files can be recreated from this one, if necessary.id2children.dbb--restricts the scope of one-level searches, that is, searches that examine an entry's immediate children.dn.dbb--controls the scope of subtree searches; that is, searches that examine an entry and all the entries in the subtree beneath it.dn2id.dbb--begins all searches efficiently by mapping an entry's distinguished name to its ID number.
Creating Indexes from the Server Manager
-
Note
-
The directory server generates index entries only when database entries are
created or modified. For this reason, the following procedure alone is not
enough if you want to create or modify an index for attributes that already exist
in your database. If you want to create an index for a currently existing
attribute, create your new index setting using this procedure, and then use the
procedure outlined in "Indexing Currently Existing Attributes" on page 164.
- Go to Database Management | Attribute Indexing.
If you want to create an index for a language other than english, enter the OID for the collation order you want to use in the Matching Rules field. You can index the attribute using multiple languages by listing multiple OIDs separated by commas (but no whitespace). For a list of languages and their associated OIDs, see Table D.1 on page 500.
Note that if an index already exists and you just want to add an international OID value to that index, you can do so by adding the appropriate value to that index's Matching Rules field. However, you should then perform the procedure as described in "Indexing Currently Existing Attributes" on page 164.
- places the new index in its alphabetical order in the list of indexed attributes
- places a new blank Attribute field at the bottom of the form
Creating Indexes Using slapd.dynamic_ldbm.conf
You can create new indexes from the command line by using the index parameter in slapd.dynamic_ldbm.conf.
Note
You can perform this same operation using
Do the following:
slapd.conf. However, you will
not be able to manage indexes from the server manager that have been added
to slapd.conf directly. For best results, perform these activities in
slapd.dynamic_ldbm.conf.
- Edit
slapd.dynamic_ldbm.conf(for a description of where the configuration files reside in your directory server installation, see "Finding the Configuration Files" on page 31). - Add an
indexparameter of the form: - When you are finished editing the
slapd.dynamic_ldbm.conffile, restart the directory server.
index <attribute> [<list of indexes>][<list of OIDs>]
pres, eq, sub, and/or approx, and <list of OIDs> is a list of
international collation OIDs. Note that if you omit <list of indexes> and
instead you specify just <list of OIDs> you must denote the null list of
indexes with double quotation marks ("").
For example:
index cn,telephoneNumber pres,eq,sub
index cn "" 2.16.840.1.113730.3.3.2.15.1
index cn eq,sub 2.16.840.1.113730.3.3.2.15.1
index cn
none to specify that no indexes are to be maintained for the
attribute. For example:
index cn none
default to specify the list of all attributes not otherwise
identified in an index parameter. For example:
index default none
Indexing Currently Existing Attributes
If you are adding an attribute that you have never before stored in the database, then you can skip this section because the directory server will automatically generate the appropriate index as you add the new attribute to entries in your database. Simply make sure that you have created the desired index setting before you start using the new attribute with your database.
For details on creating new index settings, refer to either "Creating Indexes from the Server Manager" on page 161, "Creating Indexes Using slapd.dynamic_ldbm.conf" on page 162, or "Creating International Index Entries" on page 165.
If you have created a new index setting for an attribute that your database already uses, then you must reimport your database from LDIF to generate the index for the currently existing attribute. You must do this if you add a new type of index for the currently existing attribute, or if you are adding a new international OID to an existing index. Do the following:
- Convert your existing database using the method described in "Converting Databases to LDIF" on page 62. If you decide to use
db2ldifto generate the LDIF file, do not specify the -n parameter. - Update
slapd.confwith the new index parameter as described in "Creating Indexes from the Server Manager" on page 161, or "Creating Indexes Using slapd.dynamic_ldbm.conf" on page 162. - Reimport the LDIF file as described in "Managing Databases Using LDIF" on page 60.
Creating International Index Entries
You can create international indexes for the locales you support to speed up international searches. The process for creating an international index is similar to the process for creating regular indexes, except that you associate a collation order with the attributes to be indexed.
You can create international indexes by
Creating International Indexes From the Server Manager
-
Note
-
The directory server generates index entries only when database entries are
created or modified. For this reason, the following procedure alone is not
enough if you want to create or modify an international index for attributes that
already exist in your database. If you want to create an index for a currently
existing attribute, create your new index setting using this procedure, and then
use the procedure outlined in "Indexing Currently Existing Attributes" on
page 164.
- Go to Database Management | Attribute Indexing.
- Identify the attribute for which you want to create an international index.
- If the attribute is already indexed in another language, find the attribute on the list and add the OID for the collation order you want to use in the Matching Rules field. For a list of languages and their associated OIDs, see Table D.1. You can index the attribute using multiple languages by listing multiple OIDs separated by commas (but no whitespace).
- If the attribute is not already indexed in another language, scroll to the bottom of the form and enter the name of the attribute in the Attribute to be Indexed field. Click the types of indexes you want maintained for the attribute and type the OID(s) for the languages in which you want the attribute indexed in the Matching Rules. For a list of languages and their associated OIDs, see Table D.1. You can index the attribute using multiple languages by listing multiple OIDs separated by commas (but no whitespace).
Creating International Indexes Using slapd.dynamic_ldbm.conf
Note
The directory server generates index entries only when database entries are
created or modified. For this reason, the following procedure alone is not
enough if you want to create an international index for attributes that already
exist in your database. If you want to create an international index for a
currently existing attribute, create your new index setting using this procedure,
and then use the procedure outlined in "Indexing Currently Existing Attributes"
on page 164.
You can create international indexes by editing the slapd.dynamic_ldbm.conf file to add an index parameter that includes the object identifier (OID) for the languages in which you want the attribute indexed.
You can either
- Add a new index parameter to create an international index for an attribute that has not been indexed previously
- Edit an existing index parameter to add an international index for an already indexed attribute
Creating a New International Index Using slapd.dynamic_ldbm.conf
To create an international index for an attribute that has not been indexed previously, do the following:- Open
slapd.dynamic_ldbm.conf(for a description of where the configuration files reside in your directory server installation, see "Finding the Configuration Files" on page 31). - On any line below the database parameter, add an index parameter in the form:
<attribute>is the attribute to be indexed.<OIDs>is a comma separated list of the OIDs for the languages in which you want the attribute indexed. For a list of languages and their corresponding OIDs, see Table D.1.
slapd.dynamic_ldbm.conf file:
index "" 2.16.840.1.113730.3.3.2.15.1
Editing an Existing Index Parameter to Add an International Index
To edit an existing index parameter to add a new international index, do the following:
- Open the
slapd.dynamic_ldbm.conffile (for a description of where the configuration files reside in your directory, see "Finding the Configuration Files" on page 31). - Add the OID(s) that correspond to the languages in which you want the attribute indexed to the end of the index parameter. For example, to add a spanish index for the cn attribute, which already has the following index parameter in
slapd.dynamic_ldbm.conf:
index cn
index cn eq,sub
index cn eq,sub 2.16.840.1.113730.3.3.2.15.1
Removing Indexes
You can delete some standard indexes and all indexes that you have created as follows:
- Go to Database Management | Attribute Indexing.
- Click Save&Apply at the bottom of the form. The index is no longer maintained for the server, although any indexes that were created previous to the deletion are still contained in the database. To eliminate these old indexes, export and reimport your database as described in "Indexing Currently Existing Attributes" on page 164.
Removing Standard Indexes
There is a set of standard indexes that you can not delete by using the Database Management | Attribute Indexing form. You can delete these indexes by editing the appropriate configuration file and restarting your server. The exception to this is the presence index for the ACI and copiedFrom attributes. There is no way to remove these indexes from your server.
To delete all other standard indexes from your server (with the exception of the presence index for the ACI and copiedFrom attributes):
- Edit
slapd.dynamic_ldbm.confto remove the index. Also, if an index is used by a specific SuiteSpot server (such as Messaging or Calendar server), you must also edit the configuration file that corresponds to that server. These configuration files are named: - Restart your server.
<NSHOME>/slapd-<serverID>/config/ns-<server>-globopt.c
onf
index cn pres,sub,eq
index cn pres,eq
slapd.dynamic_ldbm.conf and ns-mail-globopt.conf.