-
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.
43450: opt: derive constant computed columns for index selection r=andy-kimball a=andy-kimball The optimizer uses explicitly specified filter constraints to qualify available indexes during the exploration phase. It also uses implicit filter constraints derived from table check constraints. This commit adds new implicit filter constraints based on constant computed columns. Constant computed columns are based on other columns in the table that are constrained to be constant by other filters. For example: CREATE TABLE hashed ( k STRING, hash INT AS (fnv32(k) % 4) STORED, INDEX hash_index (hash, k) ) SELECT * FROM hashed WHERE k = 'andy' Here, the value of the hash column can be computed at query build time, and therefore "hash_index" selected as the lowest cost index. The resulting plan would be: scan hashed@secondary ├── columns: k:1(string!null) hash:2(int) ├── constraint: /2/1/3: [/1/'andy' - /1/'andy'] └── fd: ()-->(1) This improved ability to select indexes is useful for implementing HASH indexes, which scatter keys across N buckets (see Issue #39340). Release note (sql change): The optimizer can now derive constant computed columns during index selection. This enables more efficient HASH indexes. Co-authored-by: Andrew Kimball <[email protected]>
- Loading branch information
Showing
10 changed files
with
775 additions
and
323 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
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
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
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
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.