schema: Use ldb_schema_set_override_indexlist for faster index selection
authorAndrew Bartlett <abartlet@samba.org>
Thu, 30 Mar 2017 00:25:35 +0000 (13:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 May 2017 04:34:27 +0000 (06:34 +0200)
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 <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/schema/schema_init.c
source4/dsdb/schema/schema_set.c

index 256c46774526f8fc939d16bf3dd80590f3bfc711..c76b57cb4a93f00d5d944e48474bd364ce615261 100644 (file)
@@ -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;
 }
index d3e3cc8f55b8ccce7d7e52d9355a5dcad9bcba0c..e6d5ce627ce5a0b87d4fc1879677a5e6f159b1f0 100644 (file)
@@ -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;