From 503c7423b1b967d8543cfa0ff6b6e5cdcd720db5 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Wed, 14 Jul 2021 11:50:15 +0300 Subject: [PATCH 1/2] Update index.php using 'USE INDEX' speeds up query veeery much! Index Hints, https://dev.mysql.com/doc/refman/5.7/en/index-hints.html also this should by added to config.php to db array: 'index' => 'calldate', --- index.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 9df8f3b..9d78ae4 100644 --- a/index.php +++ b/index.php @@ -658,9 +658,11 @@ } } -if ( isset($_REQUEST['need_minutes_report']) && $_REQUEST['need_minutes_report'] == 'true' ) { - $query2 = "SELECT $group_by_field AS group_by_field, count(*) AS total_calls, sum(duration), sum(billsec) AS total_duration FROM $db_table_name $where GROUP BY group_by_field ORDER BY group_by_field ASC LIMIT $result_limit"; +$db_index = Config::get('db.index'); +$db_table_index = !empty($db_index) ? " USE INDEX ($db_index) " : ""; +if ( isset($_REQUEST['need_minutes_report']) && $_REQUEST['need_minutes_report'] == 'true' ) { + $query2 = "SELECT $group_by_field AS group_by_field, count(*) AS total_calls, sum(duration), sum(billsec) AS total_duration FROM " . $db_table_name . $db_table_index . $where . "GROUP BY group_by_field ORDER BY group_by_field ASC LIMIT $result_limit"; $tot_calls = 0; $tot_duration = 0; From 59981d7ca8d512f2ad940ef6ccc891c854a773b6 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Wed, 14 Jul 2021 11:50:39 +0300 Subject: [PATCH 2/2] Update config.php.sample --- inc/config/config.php.sample | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/config/config.php.sample b/inc/config/config.php.sample index 085eeda..75d8fb1 100644 --- a/inc/config/config.php.sample +++ b/inc/config/config.php.sample @@ -3,6 +3,7 @@ return array( ### Подключение к базе данных 'db' => array( + 'index' => 'calldate', # Тип базы, который поддерживается PDO. Например: mysql, pgsql 'type' => 'mysql', # Хост @@ -316,4 +317,4 @@ return array( ), -); \ No newline at end of file +);