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

Fix a bad SQL for check gc. #8500

Merged
merged 2 commits into from Aug 3, 2022
Merged

Conversation

evanchaoli
Copy link
Contributor

@evanchaoli evanchaoli commented Jul 27, 2022

Changes proposed by this PR

closes #8454

  • done

We have noticed deadlock problems in our prod db, then we found this slow query, in the meantime we noticed check_build_events had reached to 20 million tuples.

Explain the SQL, we can see its cost is huge:

image

Then I worked out a new SQL:

image

On our db, the new SQL takes only 2 seconds to run, while the old SQL might take hours.

Now, I have disabled component collector_checks, and use a 1 minute timer triggered pipeline to run the new SQL to do check GC. So far, it's running well.

Notes to reviewer

Release Note

  • Optimized performance of check-build-events collector.

@evanchaoli evanchaoli requested a review from a team as a code owner July 27, 2022 03:49
@evanchaoli evanchaoli added the bug label Jul 27, 2022
@evanchaoli evanchaoli added this to the v7.9.0 milestone Jul 27, 2022
@evanchaoli evanchaoli changed the title WIP: fix a bad SQL for check gc. Fix a bad SQL for check gc. Jul 27, 2022
@xtremerui
Copy link
Contributor

what's the bad of the old and the good for the new? Is it just a refactor or there is a behaviour change?

@xtremerui xtremerui removed this from the v7.9.0 milestone Jul 27, 2022
@evanchaoli evanchaoli added this to the v7.9.0 milestone Jul 28, 2022
@evanchaoli
Copy link
Contributor Author

what's the bad of the old and the good for the new? Is it just a refactor or there is a behaviour change?

This is a db performance optimization. I just added PR description.

Signed-off-by: Evan <chaol@vmware.com>
@evanchaoli
Copy link
Contributor Author

@xtremerui Why this PR cannot trigger concourse-ci to run?

Signed-off-by: Evan <chaol@vmware.com>
Copy link
Contributor

@xtremerui xtremerui left a comment

Choose a reason for hiding this comment

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

LGTM!

@xtremerui xtremerui merged commit 0b54be4 into concourse:master Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants