大网数据广告活动
域与目录服务

What Makes a Fast Query

· 52CE 我爱测

This topic lists preferred programming methods to use while querying a directory.

Consider the following performance enhancement concepts when executing a query:

  • If possible, filter on indexed attributes only. Use index attributes that you expect will generate the fewest number of hits. For more information and a comprehensive list of indexed attributes for Windows, see Active Directory Schema.
  • Search on objectCategory instead of objectClass because objectClass is not an indexed property.
  • Be aware of referrals. Consider searching the global catalog if your attributes are listed as GC replicated.
  • Avoid searching for text in the middle and at the end of a string. For example, "cn=*hille*" or "cn=*larouse".
  • Assume that a subtree search will return a large result set. Use paging when performing subtree searches. The server will then be able to stream a large result set in chunks reducing the server-side memory resources. This effectively flattens out network usage and reduces the need for sending extremely large chunks of data over the network.
  • Properly scope your searches so as to not retrieve more than is necessary.
  • Perform a complex search on multiple attributes, because it is less performance intensive than performing multiple searches. One search for an object that reads two attributes is more efficient than two searches for the same object, each returning one attribute.
  • For reading attribute with a large number of values, use range limits to minimize the search size so that you can read a few thousand members at a time. For more information about specifying attribute range limits, see Attribute Range Retrieval.
  • Bind to an object hold the binding handle for the remainder of your session. Do not bind and unbind for each call. If you are using ADO or OLE DB, do not create many connection objects.
  • Read the rootDSE once and remember its contents for the remainder of your session.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。