Skip to content

PREWHERE for queries with FINAL #31411

@filimonov

Description

@filimonov

Currently, PREWHERE is not too useful for Replacing / Collapsing tables with FINAL
See #23702 #8684 #24433, etc.

At the same time one of the obvious optimizations here is very similar to PREWHERE behavior:

SELECT *
FROM replacing_mt_table FINAL
WHERE (pk_col1, pk_col2) IN
(
    SELECT
       pk_col1,
       pk_col2
    FROM replacing_mt_table
    PREWHERE non_pk_col='val'
)
AND non_pk_col='val'

I think it should be possible to make something similar to that rewrite during PREWHERE itself.
I.e. during the filtering of the non_pk_col 'expand' the matching ranges to a full (wider) range of those PK values.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions