cockroachdb / cockroachdb/cockroach

sql: do not run FK and uniqueness checks if no rows were mutated

Open
#140,691 0 comments 0 reactions 0 assignees View on GitHub
A-sql-execution C-performance T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We currently avoid planning and running [FK cascades](https://github.com/cockroachdb/cockroach/blob/cf7847352534732dfaf1a0443cb827473db06dae/pkg/sql/distsql_running.go#L2151-L2155) and [after triggers](https://github.com/cockroachdb/cockroach/blob/cf7847352534732dfaf1a0443cb827473db06dae/pkg/sql/distsql_running.go#L2271-L2275) if there are no input rows to operate on. I believe it is safe to do a similar optimization for FK and uniqueness checks.

Jira issue: CRDB-47298

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.