-
Notifications
You must be signed in to change notification settings - Fork 805
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
perf(sql): Optimise searchForPipelinesByTrigger LIMIT and OFFSET SQL query #4698
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbyron-sf
approved these changes
Apr 14, 2024
Thank you @dbyron-sf. What is your view on backporting this to 1.33.x and 1.32.x? |
I'm not feeling so paranoid today, so let's do it :) |
@Mergifyio backport release-1.32.x release-1.33.x |
✅ Backports have been created
|
mergify bot
added a commit
that referenced
this pull request
Apr 15, 2024
…query (#4698) (#4699) * fix(jooq): Refactor query for execution history retrieval * fix(sql): Selecting only necessary fiels (cherry picked from commit a27e88a) Co-authored-by: Christos Arvanitis <[email protected]>
mergify bot
added a commit
that referenced
this pull request
Apr 15, 2024
…query (#4698) (#4700) * fix(jooq): Refactor query for execution history retrieval * fix(sql): Selecting only necessary fiels (cherry picked from commit a27e88a) Co-authored-by: Christos Arvanitis <[email protected]>
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
auto merged
Merged automatically by a bot
ready to merge
Approved and ready for merge
target-release/1.34
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.
Searching for the executions of the pipelines of an application by triggerType and eventId (Gate endpoint: applications//executions/search?triggerTypes=&eventId=) query execution is not optimal and creates high response times as the execution history of the application increases and/or the application has a lot of pipelines.
The retrievePipelinesForPipelineConfigIdsBetweenBuildTimeBoundary creates SQL queries with LIMIT 20 and OFFSET that look like this:
With this change the queries are optimised with a deferred join (see https://emmer.dev/blog/the-dangers-of-offset-with-mysql/). The new queries look like:
The above query lets the server to examine only the index (without accessing the rows) and once the desired rows are found is joined against the full table to retrieve the desired columns for the rows.
Explain plan of a single query on an App:
Before the change:
After the change:
With this change on simulated traffic for the above Application we have seen drop in response time from ~5.6sec to ~4.5sec.