Skip to content

Avoid re-evaluating expressions in filters and projections #17599

@adriangb

Description

@adriangb

This patterns shows up pretty often:

select expensive(col)
from t
where expensive(col)

A pathological case is variant / json:

select variant_get(col, 'key')
from t
from variant_get(col, 'key')

There's two issues here:

  1. Until we solve projection pushdown (Support Push down expression evaluation in TableProviders #14993) if key is not shredded we materialize the entire col and then extract key in a ProjectionExec.
  2. Even once that is resolved, or in the case that key is not shredded evaluating variant_get(col, 'key') itself is expensive we still re-compute variant_get(col, 'key') twice: once for the filter and once for the projection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions