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

Optimized how archive data is fetched from database #7023

Closed
wants to merge 1 commit into from

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Jan 15, 2015

References #6846

Now we try to make only 1 query per archive table (before there could be multiple queries per table).

In weekly archiving with very few data the number of SQL queries went from 2500 to 1000, saved 6% of execution time, 5% of memory usage. Real results could be much less significant (or more) I have no idea…

Also, please review the change because:

image

I juste tried to optimize that bit from what I could understand.

We could also consider issuing only 1 MySQL request by selecting from all tables at once using UNION, by I don't know if it could explode because of the amount of data…

Now we try to make only 1 query per archive table (before there could be multiple queries per table).

In weekly archiving with very few data the number of SQL queries went from 2500 to 1000, saved 6% of execution time, 5% of memory usage.
@mnapoli mnapoli added c: Performance For when we could improve the performance / speed of Matomo. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. labels Jan 15, 2015
@diosmosis
Copy link
Member

Looks like there's a bug in Archive.php somewhere, from the code, the result of Archive::getArchiveIds() is passed to ArchiveSelector::getArchiveData(), and Archive::getArchiveIds() returns Archive::getIdArchivesByMonth(), so the intent is to return an array whose keys have a 1-1 correspondence w/ archive tables. So the code should already do only one query per table, but something is causing it not to.

@mnapoli
Copy link
Contributor Author

mnapoli commented Jan 15, 2015

👍 thanks for the insight, I'll try to have a look at it

@mnapoli mnapoli self-assigned this Jan 15, 2015
@mnapoli mnapoli added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Jan 15, 2015
@mattab mattab added this to the Piwik 2.12.0 milestone Feb 9, 2015
@mattab
Copy link
Member

mattab commented Feb 9, 2015

Moving into 2.12 but @mnapoli feel free to take a look prior if you can. Also we can look together if it helps!

@mnapoli
Copy link
Contributor Author

mnapoli commented Feb 9, 2015

Ah yeah I had a look at the code last month but couldn't find anything to explain why there are duplicate queries. Maybe someone else wan't to have a look.

@mnapoli mnapoli closed this Feb 25, 2015
@mattab mattab modified the milestones: Piwik 2.12.0, Piwik 2.11.2 Mar 2, 2015
@mnapoli mnapoli deleted the optimization-archive-selector branch March 9, 2015 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants