Skip to content

[Enhancement] Selectivity-aware conjunct execution for ORC/Parquet readers (opt-in) #66108

Description

@Baymine

Search before asking

  • I had searched in the issues and found no similar issues.

Description

The ORC and Parquet readers evaluate every filter conjunct over all rows of a block and AND the results together, regardless of how cheap/selective each predicate is or the order the planner emitted them. An expensive predicate (e.g. a string function like split_by_string(col)[n]='x') is therefore run over the full block even when a cheap, highly-selective predicate on the same block would have filtered almost everything first.

Proposal

Add three opt-in (default off) session variables that only change the order/method of filter execution, never which rows pass:

  1. enable_scan_conjunct_reorder — static cost-based conjunct reorder (cheap predicates first).
  2. enable_scan_selective_filter — selection-vector execution: a later predicate is evaluated only on the rows earlier ones let through, producing the identical full-width result_filter/can_filter_all contract.
  3. enable_scan_adaptive_reorder — runtime reorder by measured cost/selectivity, correcting the static estimate for skewed data or unknown UDF cost.

All default off, so with the flags unset the reader path is byte-identical to today. When enabled, they change execution order/method only — results are identical.

Use case

Faster ORC/Parquet scans on queries mixing cheap selective predicates with expensive ones (e.g. string/UDF predicates).

Related issues

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

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