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

Slow query when 2000 pages view a day #5570

Closed
anonymous-matomo-user opened this issue Mar 18, 2008 · 4 comments
Closed

Slow query when 2000 pages view a day #5570

anonymous-matomo-user opened this issue Mar 18, 2008 · 4 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Milestone

Comments

@anonymous-matomo-user
Copy link

Each time I take a look at one of my site (who log 2000 pages view a day) I get a mysql slow query, that is a big problem because 2000 pages a day is very small indeed.
This is the query :

```

  1. Query_time: 21 Lock_time: 0 Rows_sent: 268 Rows_examined: 7195655
    SELECT name,
    type,
    count(distinct t1.idvisit) as nb_visits,
    count(distinct visitor_idcookie) as nb_uniq_visitors,
    count(*) as nb_hits
    FROM (piwik_log_visit as t1
    LEFT JOIN piwik_log_link_visit_action as t2 USING (idvisit))
    LEFT JOIN piwik_log_action as t3 USING (idaction)
    WHERE visit_server_date = ‘2008-03-17’
    AND idsite = ‘2’
    GROUP BY t3.idaction;

```

@anonymous-matomo-user
Copy link
Author

There are currently no indexes on the log tables. I tried to add a few and that made all the difference for me:

```
CREATE INDEX index_idvisit ON log_link_visit_action (idvisit);
CREATE INDEX index_idaction ON log_action (idaction);
CREATE INDEX index_idsite ON log_visit (idsite);
CREATE INDEX index_visit_server_date ON log_visit (visit_server_date);
```

@anonymous-matomo-user
Copy link
Author

I add index on tables, and yes it is day and night !
So add index is the good solution

@anonymous-matomo-user
Copy link
Author

If it could be useful I confirm this as a working solution.
In my monitored sites (1500~2000 visits per day) I have no more slow queries.

@mattab
Copy link
Member

mattab commented Mar 28, 2008

(In 421) – refs #5570 adding index on tables. Thanks for the suggestion

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Critical Indicates the severity of an issue is very critical and the issue has a very high priority.
Projects
None yet
Development

No branches or pull requests

2 participants