Hi, I’m currently seeing a huge performance problem on our internal Piwik installation. We have about 7,000 employees and a fairly active Intranet that we’re tracking.
Currently running 1.7.1 and our MySQL slow query log is showing this query to be the main problem:
SELECT idvisitor,
visit_last_action_time,
visit_first_action_time,
idvisit,
visit_exit_idaction_url,
visit_exit_idaction_name,
visitor_returning,
visitor_days_since_first,
visitor_days_since_order,
location_country,
location_continent,
referer_name,
referer_keyword,
referer_type,
visitor_count_visits,
visit_goal_buyer
,
custom_var_k1, custom_var_v1,
custom_var_k2, custom_var_v2,
custom_var_k3, custom_var_v3,
custom_var_k4, custom_var_v4,
custom_var_k5, custom_var_v5
FROM tracker_log_visit
WHERE visit_last_action_time >= '2012-02-28 10:57:31' AND idsite = '7' AND idvisitor = '<91><CF>x6qwM<C0>'
ORDER BY visit_last_action_time DESC
LIMIT 1;
Doing an EXPLAIN on it shows that it’s not using an index for the ORDER BY clause:
+----+-------------+-------------------+------+---------------------------------------------------------------------------+------------------------+---------+-------------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------------+------+---------------------------------------------------------------------------+------------------------+---------+-------------+------+-----------------------------+
| 1 | SIMPLE | tracker_log_visit | ref | index_idsite_config_datetime,index_idsite_datetime,index_idsite_idvisitor | index_idsite_idvisitor | 12 | const,const | 1 | Using where; Using filesort |
+----+-------------+-------------------+------+---------------------------------------------------------------------------+------------------------+---------+-------------+------+-----------------------------+
1 row in set (0.97 sec)
I see a reference to removing this clause in this changeset:
http://dev.piwik.org/trac/changeset/5897
So my question is: is it safe to go ahead and remove the ORDER BY clause to resolve the problem I’m currently seeing?
At present, I have had to remove access to Piwik as our database server runs out of connections and the server’s load average goes sky high with access enabled.
The exact same configuration was working perfectly yesterday!
Many thanks.