We’ve been running Piwik for a year now and never experienced any problems. Recently we added another site to Piwik, both combined have about 50.000 pageviews a day, so that shouldn’t be the problem. MySQL also has sufficient memory (we have enough free memory as well). We purge old logs every 2 months (61 days).
Our slow query log shows a lot of these:
# Time: 120402 22:25:20
# User@Host: nsane_piwik[nsane_piwik] @ localhost []
# Query_time: 43.315927 Lock_time: 0.000127 Rows_sent: 0 Rows_examined: 824
use piwik_analytics;
SET timestamp=1333405520;
( 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
,
0 as priority
FROM piwik_log_visit
WHERE visit_last_action_time >= '2012-04-02 21:54:37' AND idsite = '1' AND config_id = '_8Í\r•ô°'
ORDER BY visit_last_action_time DESC
LIMIT 1
)
UNION
( 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
,
1 as priority
FROM piwik_log_visit
WHERE visit_last_action_time >= '2012-04-02 21:54:37' AND idsite = '1' AND idvisitor = 'óPHÙÖÈìâ'
LIMIT 1
)
ORDER BY priority DESC
LIMIT 1;
Always the same query (SELECT idvisitor). I see no reason for this delay, do any of you? The time it takes for the query to run is between 10 seconds and 60 seconds…