From d3445b316dcb4c3139f83ca1adae85c3e7ad67c4 Mon Sep 17 00:00:00 2001 From: dzenichev Date: Tue, 6 Sep 2022 15:25:48 +0200 Subject: [PATCH] MT#55307 SQL DB: kamailio.acc table, additional indexing We have to concern slow selections like this: "SELECT a.callid FROM acc a WHERE a.method = 'INVITE' GROUP BY a.callid LIMIT 0,200000;" which can take procesisng time over 10 sec (as reported in the WF ticket). As a simple solution, we can give an additional index to the 'acc' table: KEY `method_callid_idx` (`method`,`callid`) Which will give us an indexation on selecitons with the WHERE clause on 'method' column. Without the index (explain of the selection): *************************** 1. row *************************** id: 1 select_type: SIMPLE table: a type: range possible_keys: NULL key: callid_method_idx key_len: 817 ref: NULL rows: 2 Extra: Using where; Using index for group-by With the index (explain of the selection): *************************** 1. row *************************** id: 1 select_type: SIMPLE table: a type: ref possible_keys: method_callid_idx key: method_callid_idx key_len: 50 ref: const rows: 1 Extra: Using where; Using index The newer index is not to be mixed with the previously existing one: KEY `callid_method_idx` (`callid`,`method`) Change-Id: Ie8a4ab102adb8788d9e273bd5a9edf1ddbb702bf --- db_scripts/diff/15739.down | 4 ++++ db_scripts/diff/15739.up | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 db_scripts/diff/15739.down create mode 100644 db_scripts/diff/15739.up diff --git a/db_scripts/diff/15739.down b/db_scripts/diff/15739.down new file mode 100644 index 00000000..ff31836d --- /dev/null +++ b/db_scripts/diff/15739.down @@ -0,0 +1,4 @@ +SET sql_log_bin=0; +USE kamailio; + +DROP INDEX method_callid_idx ON acc; diff --git a/db_scripts/diff/15739.up b/db_scripts/diff/15739.up new file mode 100644 index 00000000..2640c462 --- /dev/null +++ b/db_scripts/diff/15739.up @@ -0,0 +1,4 @@ +SET sql_log_bin=0; +USE kamailio; + +CREATE INDEX method_callid_idx ON acc (method,callid);