cockroachdb / cockroachdb/cockroach

sql: distributed UniqueKey operator

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

Description

Sometimes when decorrelating, we call `EnsureKey` to add a unique key to an input. Currently this wraps the input in the same `Ordinality` operator as used by `WITH ORDINALITY`. This works, but `WITH ORDINALITY` has stricter requirements than decorrelation: `WITH ORDINALITY` requires the output to be the natural numbers in increasing order, without gaps, whereas decorrelation only needs the rows to be unique.

@msirek relaxed one requirement for decorrelation by [pushing selects](https://github.com/cockroachdb/cockroach/pull/110593) into `Ordinality` when they are not from `WITH ORDINALITY`. But we still only have single-node execution of `Ordinality`.

It would be nice if we could distribute this unique key operation, maybe by using the nodeid of the local node. @msirek has already prototyped the optimizer changes [here](https://github.com/cockroachdb/cockroach/pull/109903), but we have not yet implemented it in DistSQL.

Jira issue: CRDB-31645

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.