-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: improve precision of index spans to scan for multi-column-family single-row fetches #18168
Copy link
Copy link
Closed
Labels
A-sql-optimizerSQL logical planning and optimizations.SQL logical planning and optimizations.C-performancePerf of queries or internals. Solution not expected to change functional behavior.Perf of queries or internals. Solution not expected to change functional behavior.
Description
Suppose we have a table and a query:
CREATE TABLE a (a INT PRIMARY KEY, b INT, c INT, FAMILY(a), FAMILY(b), FAMILY(c);
INSERT INTO a VALUES(1,2,3);
SELECT b FROM a WHERE a=1;
Currently, this query will cause a scan from /a/primary/1 -> /a/primary/2, even though ideally we'd only need to scan the key at /a/primary/1/b.
We have enough information to improve this scan, since we know that c is not a needed column, a is the primary index and therefore unique, and we have an equality constraint on a.
We should consider improving the algorithm in spanFromLogicalSpan to incorporate all of this information into its final output span.
cc @danhhz @andreimatei @petermattis based on our earlier conversation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-sql-optimizerSQL logical planning and optimizations.SQL logical planning and optimizations.C-performancePerf of queries or internals. Solution not expected to change functional behavior.Perf of queries or internals. Solution not expected to change functional behavior.