-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76961: opt: remove redundant arbiter indexes r=mgartner a=mgartner We select all unique indexes and unique constraints as arbiters for `INSERT .. ON CONFLICT` statements without explicit conflict columns or constraints. In some cases, unique constraint arbiters make unique index arbiters redundant, which results in query plans that perform unnecessary work to check for conflicts. Most notably, redundant unique indexes are chosen as arbiters for both partitioned and hash-sharded indexes which synthesize `UNIQUE WITHOUT INDEX` constraints. For example, consider the table and statement which mimics a simplified hash-sharded index: CREATE TABLE t ( a INT, shard_a INT, UNIQUE INDEX shard_a_a_key (shard_a, a), UNIQUE WITHOUT INDEX a_key (a) ) INSERT INTO t VALUES (1, 2) ON CONFLICT DO NOTHING There is no need to use both `shard_a_a_key` and `a_key` as arbiters for the `INSERT` statement because any conflict in `shard_a_a_key` will also be a conflict in `a_key`. Only `a_key` is required to be an arbiter. This commit removes these redundant arbiter indexes, which improves query plans. Fixes #75498 Release note (performance improvement): The optimizer produces more efficient query plans for `INSERT .. ON CONFLICT` statements that do not have explicit conflict columns or constraints and are performed on partitioned tables. 76963: sql: use IndexFetchSpec in JoinReader r=yuzefovich a=RaduBerinde #### descpb: add IndexID to IndexFetchSpec Release note: None #### span: make Builder and Splitter without descriptors Allow creation of span.Builder and span.Splitter without table and index descriptors. Release note: None #### rowexec: move eqCols to hashjoiner This commit moves eqCols from joinerBase to hashJoiner because that is the only processor that uses them. This simplifies the initialization code for other processors. Release note: None #### sql: use IndexFetchSpec in JoinReader This commit changes `JoinReader` to use an `IndexFetchSpec` (plus a list of family IDs for span splitting) instead of table and index descriptors. As part of making this switch, the "internal schema" of the processor no longer contains all table columns; instead it contains the specific `FetchedColumns` in the spec. This simplifies both planning and execution code. Release note: None Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Radu Berinde <[email protected]>
- Loading branch information
Showing
73 changed files
with
1,863 additions
and
1,524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
312 changes: 108 additions & 204 deletions
312
pkg/ccl/logictestccl/testdata/logic_test/partitioning_hash_sharded_index_query_plan
Large diffs are not rendered by default.
Oops, something went wrong.
355 changes: 131 additions & 224 deletions
355
pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_hash_sharded_index_query_plan
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.