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

release-20.2: jobs: invert status predicate to improve query plan #57591

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

ajwerner
Copy link
Contributor

@ajwerner ajwerner commented Dec 5, 2020

Backport 1/1 commits from #57587.

/cc @cockroachdb/release


The jobs code regularly scans the set of adoptable jobs (generally small) to
find if there are abandoned jobs in need of adoption. In #56864 we added a
predicate to improve these loops to stop touching already terminal jobs. This
was a big improvement in what data is written but not as big of an improvement
in what data was read. When the jobs table is large, the queries, prior to this
patch, performed expensive full table scans. With this patch the query plan is
improved to utilize the index. Were there a check constraint indicating the
allowable values of status, then the optimizer could have created the same
plan. However, there isn't.

Release note (bug fix): Remove system.jobs full table scan which is
expensive in the face of many completed jobs.

The jobs code regularly scans the set of adoptable jobs (generally small) to
find if there are abandoned jobs in need of adoption. In cockroachdb#56864 we added a
predicate to improve these loops to stop touching already terminal jobs. This
was a big improvement in what data is written but not as big of an improvement
in what data was read. When the jobs table is large, the queries, prior to this
patch, performed expensive full table scans. With this patch the query plan is
improved to utilize the index. Were there a check constraint indicating the
allowable values of status, then the optimizer could have created the same
plan. However, there isn't.

Release note (bug fix): Remove system.jobs full table scan which is
expensive in the face of many completed jobs.
@ajwerner ajwerner requested a review from spaskob December 5, 2020 00:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner merged commit c15afb6 into cockroachdb:release-20.2 Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants