Add force index in report mysql request to avoid full scan table

This commit is contained in:
Nicolas Le Goff
2012-11-14 16:58:16 +01:00
parent 291e46c21a
commit 3c318c5c6e
8 changed files with 72 additions and 76 deletions

View File

@@ -61,8 +61,8 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
$this->sql = "
SELECT TRIM(" . $this->getTransQuery($this->groupby) . ")
as " . $this->groupby . ", SUM(1) as nb
FROM (log)
INNER JOIN log_colls ON (log.id = log_colls.log_id)";
FROM log FORCE INDEX (date_site)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)";
if ($report_filter['sql'])
$this->sql .= " WHERE " . $report_filter['sql'];
@@ -86,8 +86,8 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
$sql = '
SELECT DISTINCT(' . $this->getTransQuery($field) . ') as val
FROM (log)
INNER JOIN log_colls ON (log.id = log_colls.log_id)';
FROM log FORCE INDEX (date_site)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)';
if ($report_filter['sql'])
$sql .= ' WHERE ' . $report_filter['sql'];