Can you help me to create a join to decrease the time for a particular query to the piwik_log_visit table?
Slow-query.log:
Time: 191011 9:17:08
User@Host: piwik[piwik] @server [192.168.111.231]
Thread_id: 5598 Schema: piwik QC_hit: No
Query_time: 20.595598 Lock_time: 0.000061 Rows_sent: 1 Rows_examined: 25083
SET timestamp=1570781828;
SELECT /* Core */
count(distinct log_visit.idvisitor) AS `1`,
count(*) AS `2`,
sum(log_visit.visit_total_actions) AS `3`,
max(log_visit.visit_total_actions) AS `4`,
sum(log_visit.visit_total_time) AS `5`,
sum(case log_visit.visit_total_actions when 1 then 1 when 0 then 1 else 0 end) AS `6`,
sum(case log_visit.visit_goal_converted when 1 then 1 else 0 end) AS `7`,
count(distinct log_visit.user_id) AS `39`
FROM
piwik_log_visit AS log_visit
WHERE
( log_visit.visit_last_action_time >= '2019-10-09 23:00:00'
AND log_visit.visit_last_action_time <= '2019-10-10 22:59:59'
AND log_visit.idsite IN ('2') )
AND
( (log_visit.visitor_returning = '1' OR log_visit.visitor_returning = '2' ));