From: Andrew Bartlett Date: Thu, 30 Mar 2017 00:25:35 +0000 (+1300) Subject: schema: Use ldb_schema_set_override_indexlist for faster index selection X-Git-Tag: ldb-1.1.31~185 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7c36a7142198c9a8efb769627af4488e0bb5dc0;p=thirdparty%2Fsamba.git schema: Use ldb_schema_set_override_indexlist for faster index selection This allows Samba to provide a binary tree lookup for the existance of an index on the attribute rather than the O(n) lookup that was being done for each attribute during a search or modify Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher Reviewed-by: Garming Sam --- diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index 256c4677452..c76b57cb4a9 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -514,6 +514,10 @@ static int dsdb_schema_setup_ldb_schema_attribute(struct ldb_context *ldb, a->flags |= LDB_ATTR_FLAG_SINGLE_VALUE; } + if (attr->searchFlags & SEARCH_FLAG_ATTINDEX) { + a->flags |= LDB_ATTR_FLAG_INDEXED; + } + return LDB_SUCCESS; } diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index d3e3cc8f55b..e6d5ce627ce 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -71,6 +71,7 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, /* setup our own attribute name to schema handler */ ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema); + ldb_schema_set_override_indexlist(ldb, true); if (!write_indices_and_attributes) { return ret;