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

Make sure query in system check uses index #16372

Merged
merged 4 commits into from Sep 3, 2020
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 2, 2020

@tsteur tsteur added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Sep 2, 2020
@tsteur tsteur added this to the 4.0.0 milestone Sep 2, 2020
@@ -54,7 +56,8 @@ private function hadVisitsInLastDays($numDays)
$time = Date::now()->subDay($numDays)->getDatetime();

try {
$row = Db::fetchOne('SELECT idsite from ' . $table . ' where visit_last_action_time > ? LIMIT 1', $time );
$idSites = $this->getImplodedIdSitesSecure();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this, but could we also use the index if we just did something like, AND idsite > 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK Mysql doesn't support using both index parts (idsite and visit_last_action_time) when both are a range. MySQL stops using the index after the first range. So idsite > 0 would be a range and therefore it would only use the idsite index.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, can Site::getIdSitesFromIdSitesString('all') be used (w/ superuser access) to get all of them? Not really necessary, but might use existing cached data and reduce amount of code here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated it @diosmosis

@diosmosis diosmosis merged commit 21cafb0 into 4.x-dev Sep 3, 2020
@diosmosis diosmosis deleted the indexdiagnostic branch September 3, 2020 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants