[Bug] Slow archiving query because of MySQL optimizer making wrong decision #21635
Closed
4 tasks done
Labels
Bug
For errors / faults / flaws / inconsistencies etc.
c: Performance
For when we could improve the performance / speed of Matomo.
Milestone
What happened?
Below is a temporary segment table being created and the query had been running for > 1900 seconds:
The query looks like this
The query is slow because MySQL starts with
log_action
rather thanlog_visit
:When forcing the join order using a hint (or when using the join prefix hint to prefer
log_visit
first), then MySQL chooses the right order:As a result, the query time improved to 21 seconds. That's a 100x improvement:
There are say 20K actions of type 3 in this case but 100K log_visits for the day so MySQL falsely choose to start with
log_action
.This results in very long running queries where Matomo cannot catch up archiving and ultimately reports may not become available.
What should happen?
Matomo should ensure that the query is fast.
How can this be reproduced?
Can provide details internally.
The query in question is but reproducing this would depend on the data structure etc.
Matomo major version
Matomo 5
Matomo minor or patch Version
5
PHP version
.
Server operating system
.
What browsers are you seeing the problem on?
No response
Computer operating system
.
Relevant log output
No response
Validations
The text was updated successfully, but these errors were encountered: