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

Avoid including unnecessary pg_locks references when counting jobs #789

Merged
merged 1 commit into from
Jan 7, 2023

Conversation

mkrfowler
Copy link
Contributor

We've been observing some performance limitations with the GoodJob dashboard. I believe this to be largely a consequence of performing live counts on an insufficiently-pruned table relative to the available database resource, but I noted that the dashboard count queries include a join against pg_locks. In the event that there are a substantial number of e.g. succeeded jobs, this actually gets quite expensive, and isn't necessary to satisfy counts.

This PR is a bit of an opportunistic approach to avoid that cost.

Previously, the executed query for in particular the `succeeded` scope included
a join against `pg_locks`.  This is not particularly useful, and unfortunately
triggers evaluation of that join criterion, with noticable expense as job volume
grows.

This change modifies the jobs filter logic to only include those joins in the
necessary locations (`running`) and when loading records for practical
enumeration.
@bensheldon
Copy link
Owner

@mkrfowler thank you! The Dashboard is very unoptimized so I appreciate the help. I want to poke at it locally for a bit, but I think it'll be good 👍

@bensheldon bensheldon added bug Something isn't working refactor Code changes that do not introduce new features and removed bug Something isn't working labels Jan 7, 2023
@bensheldon bensheldon merged commit 3709abd into bensheldon:main Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code changes that do not introduce new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants