Skip to content

opt: propagate properties through some projects #137501

Open
@yuzefovich

Description

@yuzefovich
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
CREATE TABLE kv (k INT PRIMARY KEY, v INT);
EXPLAIN SELECT * FROM kv AS t1, kv AS t2 WHERE t1.k = t2.k + 1;

I'm surprised that in the hash join only the left equality columns marked as a key - t2.k is a key, so simple expressions like t2.k + 1 preserve that property (perhaps modulo overflow?). We should propagate it if possible.

The same thing for ordering:

EXPLAIN SELECT * FROM kv AS t1 INNER MERGE JOIN  kv AS t2 ON t1.k = t2.k + 1; 

we shouldn't need to sort the right input to the merge join.

Jira issue: CRDB-45619

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions