diff options
author | Sean Bright <sean.bright@gmail.com> | 2017-12-07 15:19:40 -0500 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2017-12-10 12:51:09 -0600 |
commit | d9843c84efc0fc38c4c1455857226fe2a04bf430 (patch) | |
tree | 8c2c1b166901aec64a95817d9913b2f277ec9a59 /res | |
parent | 52de5a05f0f6bf534c0642a4f43daa562b5b9004 (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.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/res/res_sorcery_astdb.c b/res/res_sorcery_astdb.c index 8b93b57ba..87823be0d 100644 --- a/res/res_sorcery_astdb.c +++ b/res/res_sorcery_astdb.c @@ -334,14 +334,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; } |