Skip to content

release-20.1: sql: add cache for jobs to avoid querying system.jobs to find existing jobs#50923

Merged
RichardJCai merged 1 commit intocockroachdb:release-20.1from
RichardJCai:backport20.1-50848
Jul 2, 2020
Merged

release-20.1: sql: add cache for jobs to avoid querying system.jobs to find existing jobs#50923
RichardJCai merged 1 commit intocockroachdb:release-20.1from
RichardJCai:backport20.1-50848

Conversation

@RichardJCai
Copy link
Copy Markdown
Contributor

@RichardJCai RichardJCai commented Jul 2, 2020

Backport 1/1 commits from #50848.

/cc @cockroachdb/release


Currently, we perform a loop through all existing jobs which involves
querying a system table to check if there is an existing job for the current
table undergoing a schema change. To avoid this query, we can use a cache
to map TableIDs to jobs.

Fixes #50165, #50783

Release note (bug fix): Fixed regression where granting privileges and dropping objects
would be slow when performed on a large number of objects due to unnecessary queries
for looking up jobs in the system.jobs.
Previously we did a quadratic number of queries based on the number of objects.
After this fix we do a linear number of queries based on the number of objects which
significantly improves the speed of dropping multiple objects or granting
multiple privileges to a user.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@RichardJCai RichardJCai requested review from ajwerner and rohany July 2, 2020 15:50
@rohany
Copy link
Copy Markdown
Contributor

rohany commented Jul 2, 2020

Wait this (and the original PR) need a release note about the performance regression that was fixed.

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

good catch. Otherwise :lgtm:

Reviewed 5 of 5 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rohany)

@RichardJCai
Copy link
Copy Markdown
Contributor Author

Wait this (and the original PR) need a release note about the performance regression that was fixed.

Ah true, what should I do about the original PR?

@rohany
Copy link
Copy Markdown
Contributor

rohany commented Jul 2, 2020

what should I do about the original PR?

I don't know... Ask in the slack?

@RichardJCai RichardJCai force-pushed the backport20.1-50848 branch 2 times, most recently from a4494e1 to 029c25e Compare July 2, 2020 16:25
…ng job

Currently, we perform a loop through all existing jobs which involves
querying a system table to check if there is an existing job for the current
table undergoing a schema change. To avoid this query, we can use a cache
to map TableIDs to jobs.

Fixes cockroachdb#50165, cockroachdb#50783

Release note (bug fix): Fixed regression where granting privileges and dropping objects
would be slow when performed on a large number of objects due to unnecessary queries
for looking up jobs in the system.jobs.
Previously we did a quadratic number of queries based on the number of objects.
After this fix we do a linear number of queries based on the number of objects which
significantly improves the speed of dropping multiple objects or granting
multiple privileges to a user.
@RichardJCai RichardJCai force-pushed the backport20.1-50848 branch from 029c25e to 80cd3f4 Compare July 2, 2020 17:39
@RichardJCai RichardJCai merged commit 5feded9 into cockroachdb:release-20.1 Jul 2, 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.

4 participants