Export (0) Print
Expand All

Creating Efficient Queries

The following list identifies several important concepts to consider when creating an efficient query.

  • Ensure that the query filter contains at least one indexed attribute. For more information, see Indexed Attributes.
  • Search for objectCategory instead of objectClass, because objectClass is not an indexed property. The statement "objectClass=xyz" refers to directory objects in which "xyz" represents any class in the object class hierarchy, whereas "objectCategory=xyz", refers to those directory objects in which "xyz" identifies a specific class in the object class hierarchy. The objectClass property can take multiple values, whereas objectCategory takes a single value and is, thus, better suited for type matching of objects in a directory search.
  • Avoid searching for text in the middle and on the end of a string. For example, "cn=*hille*" or "cn=*larouse". Using more specific matching criteria tends to increase search performance. This is because Active Directory Domain Services will evaluate all predicates, identifies the indices, and then chooses one index most likely to yield the smallest set of returned values. This technique does not work well with mid- and end-string searches. If you have no other option other than using these searches, you can define a tuple index for the attribute. For more details about tuple indexes see How Tuple Indexing Works.
  • Use the global catalog if you are considering subtree searches. Chasing referrals requires extensive resources. For more information, see Specifying Other Search Options.
  • Assume that a subtree search will return a large result set. Use paging when performing subtree searches. The server will stream a large result set in chunks reducing the server side memory resources. This minimizes network usage and reduces the need for sending large chunks of data over a network. For more information, see Specifying Other Search Options.
  • Use multiple attributes in for a search. One search of an object that reads two attributes is more efficient than two searches of the same object, each returning one attribute.
  • Bind to an object one time and hold the binding handle for the rest of the session. Do not bind and unbind for each call. If you use ADO or OLE DB, do not create many connection objects.
  • Read the rootDSE one time and remember its contents for the rest of your session. For more information, see Serverless Binding and RootDSE.
  • Persist references to objects as GUIDs, not distinguished names, in order to be rename and delete safe. For more information, see Using objectGUID to Bind to an Object.

 

 

Show:
© 2014 Microsoft