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

opt, sql: parallelize uniqueness checks when possible #58942

Closed
rytaft opened this issue Jan 13, 2021 · 5 comments
Closed

opt, sql: parallelize uniqueness checks when possible #58942

rytaft opened this issue Jan 13, 2021 · 5 comments
Labels
A-multiregion Related to multi-region A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-multiregion

Comments

@rytaft
Copy link
Collaborator

rytaft commented Jan 13, 2021

Currently, uniqueness checks are run after a mutation completes, as a series of post-queries (similar to foreign key checks). We could reduce latency by parallelizing all of these checks. It may also be possible to run the uniqueness checks in parallel with the mutation itself. If the mutation only affects a single row, the uniqueness check can be trivially parallelized with the mutation (particularly if the mutation is an INSERT with VALUES input). If it affects multiple rows, it may or may not be possible to parallelize. This is also relevant for enabling the insert fast path with uniqueness checks, as described in #58047.

cc @nvanbenschoten @andreimatei

Epic CRDB-26292

Jira issue: CRDB-3356

@rytaft rytaft added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) C-performance Perf of queries or internals. Solution not expected to change functional behavior. A-sql-optimizer SQL logical planning and optimizations. A-sql-execution Relating to SQL execution. A-multiregion Related to multi-region T-multiregion labels Jan 13, 2021
@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@yuzefovich
Copy link
Member

Just randomly stumbled on this issue, and I think #96123 fixes it, should we close it?

@rytaft
Copy link
Collaborator Author

rytaft commented Mar 20, 2023

Yea I think so! Although what do you think about the additional suggestion for running the checks in parallel with the mutation itself in some cases?

@yuzefovich
Copy link
Member

That seems like a good idea although orthogonal to work we did in #96123. My intuition says that in the general case parallelizing the mutation and the postquery checks is not possible, but implementing some kind of fastpath for uniqueness checks when mutating a single row would be nice. Perhaps it deserves a separate issue? Or rephrasing this issue to be specifically about that?

@rytaft
Copy link
Collaborator Author

rytaft commented Mar 20, 2023

There's already #58047 which covers the fast path, I'll just add a note there and close this.

@rytaft
Copy link
Collaborator Author

rytaft commented Mar 20, 2023

Done, closing this.

@rytaft rytaft closed this as completed Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-multiregion Related to multi-region A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-multiregion
Projects
None yet
Development

No branches or pull requests

3 participants