Skip to content

sql: improve precision of index spans to scan for multi-column-family single-row fetches #18168

@jordanlewis

Description

@jordanlewis

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.

Metadata

Metadata

Assignees

Labels

A-sql-optimizerSQL logical planning and optimizations.C-performancePerf of queries or internals. Solution not expected to change functional behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions