summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorSean Bright <sean.bright@gmail.com>2017-12-07 15:19:40 -0500
committerSean Bright <sean.bright@gmail.com>2017-12-10 12:41:51 -0600
commita4b291029fc79b143a94bfbda20a32ef52321539 (patch)
treefca7fc43bac1885c6d7006a323da960a15d22e72 /res
parent54a86779a3d1cc2a1c859d76180f155865713bb5 (diff)
astdb: Improve prefix searches in astdb
Using the LIKE operator requires a full table scan of 'astdb', whereas a comparison operation is able to use the primary key index. This patch adds a new function to the AstDB API for quick prefix matches and updates res_sorcery_astdb to utilize it. This showed substantial performance improvement in my test environment. Related to ASTERISK~26806, but does not completely resolve it. Change-Id: I7d37f9ba2aea139dabf2ca72d31fbe34bd9b2fa1
Diffstat (limited to 'res')
-rw-r--r--res/res_sorcery_astdb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/res/res_sorcery_astdb.c b/res/res_sorcery_astdb.c
index fee857525..135709ebd 100644
--- a/res/res_sorcery_astdb.c
+++ b/res/res_sorcery_astdb.c
@@ -336,14 +336,14 @@ static void sorcery_astdb_retrieve_prefix(const struct ast_sorcery *sorcery, voi
const char *family_prefix = data;
size_t family_len = strlen(family_prefix) + strlen(type) + 1; /* +1 for slash delimiter */
char family[family_len + 1];
- char tree[prefix_len + sizeof("%")];
+ char tree[prefix_len + 1];
RAII_VAR(struct ast_db_entry *, entries, NULL, ast_db_freetree);
struct ast_db_entry *entry;
- snprintf(tree, sizeof(tree), "%.*s%%", (int) prefix_len, prefix);
+ snprintf(tree, sizeof(tree), "%.*s", (int) prefix_len, prefix);
snprintf(family, sizeof(family), "%s/%s", family_prefix, type);
- if (!(entries = ast_db_gettree(family, tree))) {
+ if (!(entries = ast_db_gettree_by_prefix(family, tree))) {
return;
}