什么是 LDAP 索引以及它们如何工作?

What are LDAP indexes and how do they work?

我目前正忙于学习LDAP。我有索引问题。我知道它们是用来提高性能的。但是,我无法理解LDAP中索引的工作原理。例如,作为 LDAP 服务器,我正在使用 OpenDJ。在那里,我可以看到属性 sn (surname) 确实有 5 种不同的索引类型,分别是 approximate、Equality、Ordering、Presence 和 Substring。但是,只检查了 Ordering。

LDAP 索引可以看作是数据库索引。索引正在提高复杂 LDAP 搜索请求的性能。希望对您有所帮助。

I could not understand the working principle of indexes in LDAP.

与数据库中的索引相同。以加快查询和更新。可以为任何属性提供索引,但只有那些在搜索中具有特征的属性才应该被索引。与 DBMS 相比,您可以对 LDAP 数据库进行索引,因为假定的 read::write 比率要高得多,通常 9::1 或更高,而 RDBMS 的 3::1,因此索引成本插入和更新相对较少。

For example, as LDAP server, I am working with OpenDJ. There, I can see that attribute sn (surname) does have 5 different index types, which are approximate, Equality, Ordering, Presence and Substring.

这些对应于您可以在 LDAP search filter 中使用的不同运算符:

  filter     = "(" filtercomp ")"
    filtercomp = and / or / not / item
    and        = "&" filterlist
    or         = "|" filterlist
    not        = "!" filter
    filterlist = 1*filter
    item       = simple / present / substring / extensible
    simple     = attr filtertype value
    filtertype = equal / approx / greater / less
    equal      = "="
    approx     = "~="
    greater    = ">="
    less       = "<="
    extensible = attr [":dn"] [":" matchingrule] ":=" value
                 / [":dn"] ":" matchingrule ":=" value
    present    = attr "=*"
    substring  = attr "=" [initial] any [final]
    initial    = value
    any        = "*" *(value "*")
    final      = value
    attr       = AttributeDescription from Section 4.1.5 of [1]
    matchingrule = MatchingRuleId from Section 4.1.9 of [1]
    value      = AttributeValue from Section 4.1.6 of [1]

However, only Ordering is checked.

您是说在某些管理 GUI 中只选择了这个选项吗?如果是这样,则只为该属性维护一个常规的排序索引。这可以用于所有操作员,但据称速度较慢。 [我个人一直不明白为什么 LDAP 实现者认为他们根本不在数据库业务中,不使用标准数据库,而坚持提供自己的数据库。]

当客户端请求目录搜索操作时,客户端向服务器发送一个过滤器表达式,例如 (&(uid=jensen)(l=Stavanger))。然后,服务器使用适用的索引来查找具有可能匹配搜索的属性值的条目。如果没有适用的索引,则服务器可能必须遍历所有条目以查找候选匹配项。

查看所有条目对于大型目录来说是资源密集型的。因此,默认情况下为目录 root 用户保留允许用户请求搜索不存在适用索引的未索引搜索权限。

Source