mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	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
This commit is contained in:
		| @@ -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; | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user