Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USE INDEX in query #160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion inc/config/config.php.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return array(
### Подключение к базе данных
'db' => array(
'index' => 'calldate',
# Тип базы, который поддерживается PDO. Например: mysql, pgsql
'type' => 'mysql',
# Хост
Expand Down Expand Up @@ -316,4 +317,4 @@ return array(
),


);
);
6 changes: 4 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down