Improve sql query performance by removing unused payload #2195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a quick-fix to Improve a specific SQL query from 22-37s to <1s when refreshing news items.
Some details how I got to that solution:
Activate slow-queries
Revealed slow-query:
After reducing payload (
items.*
-->items.id
) the query is way faster:newest()
now only returns an entity with an id and not a complete news item anymore. All usages that I found are only using the id so i guess we are fine at the moment but maybe we need to change the function name or at least the return description.This seams to be the first function that only returns parts of an item so I was unsure how to handle it. Feel free to change PR to fit your needs :-)
See also #1322 (comment)
And maybe another valid approach is still #1322 (comment) (not tested)
Checklist