From 3a8b67d06cf631f4d883ce40859401eb760bb0f3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Nov 2010 20:19:49 +1100 Subject: s4-ldb: added an environment varibale LDB_WARN_UNINDEXED when LDB_WARN_UNINDEXED is set, we produce warnings about unindexed searches. This makes it easier to find performance problems caused by unindexed searches. --- source4/lib/ldb/ldb_tdb/ldb_search.c | 14 +++++++------- source4/lib/ldb/ldb_tdb/ldb_tdb.c | 4 ++++ source4/lib/ldb/ldb_tdb/ldb_tdb.h | 2 ++ 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/ldb_tdb') diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 5df1e4d59e..b58243c26c 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -578,13 +578,13 @@ int ltdb_search(struct ltdb_context *ctx) * callback error */ if ( ! ctx->request_terminated && ret != LDB_SUCCESS) { /* Not indexed, so we need to do a full scan */ -#if 0 - /* useful for debugging when slow performance - * is caused by unindexed searches */ - char *expression = ldb_filter_from_tree(ctx, ctx->tree); - printf("FULL SEARCH: %s\n", expression); - talloc_free(expression); -#endif + if (ltdb->warn_unindexed) { + /* useful for debugging when slow performance + * is caused by unindexed searches */ + char *expression = ldb_filter_from_tree(ctx, ctx->tree); + ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb FULL SEARCH: %s\n", expression); + talloc_free(expression); + } if (match_count != 0) { /* the indexing code gave an error * after having returned at least one diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 2e88989d57..066d4085bb 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -1463,6 +1463,10 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, return LDB_ERR_OPERATIONS_ERROR; } + if (getenv("LDB_WARN_UNINDEXED")) { + ltdb->warn_unindexed = true; + } + ltdb->sequence_number = 0; module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops); diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h index 493c276b13..33313b00da 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h @@ -34,6 +34,8 @@ struct ltdb_private { struct ltdb_idxptr *idxptr; bool prepared_commit; int read_lock_count; + + bool warn_unindexed; }; /* -- cgit