opt: avoid planning uniqueness checks for upsert if new values are null #58300
Labels
A-multiregion
Related to multi-region
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
T-sql-queries
SQL Queries Team
We currently plan some unnecessary uniqueness checks on
UNIQUE WITHOUT INDEX
columns when planningUPSERT
queries. There are a couple of reasons for this:UPSERT
may need to be wrapped in anEnsureUpsertDistinctOn
and aLeftJoin
. Since the functionOutputColumnIsAlwaysNull
doesn't recurse intoJOIN
s orGROUP BY
s, we may not be able to determine that a particular column is alwaysNULL
. We'll need to update this function to add support forJOIN
s andGROUP BY
s. This will fix the case where the insert and update mapping for a column are the same (bothNULL
).NULL
, and (b) none of the columns in the unique constraint are being updated (i.e., they don't have an update mapping).Epic CRDB-13964
Jira issue: CRDB-3411
The text was updated successfully, but these errors were encountered: