Skip to content

Re-land Decimal filter selectivity estimation (#25790) without the TPC-H Q18 regression #27146

Open

Description

@asolimando

Is your feature request related to a problem or challenge?

#25790 added interval analysis to estimate filter selectivity on Decimal columns. On TPC-H Q18 this change made the plan use a much worse join order: the query took about 233 s and 22 GB of peak memory, compared with about 7 s and 4 GB before (#27108). #27145 reverts the change for the 56 release.

Describe the solution you'd like

Find out why the new estimate changes the Q18 join order. Then re-land #25790 with a TPC-H Q18 plan check, so that this regression cannot return.

cc @shrivasshankar @devanbenz

Activity

  1. shrivasshankar commented on Nov 5, 2026

    @shrivasshankar
    Contributor

    take

  2. shrivasshankar commented on Nov 5, 2026

    @shrivasshankar
    Contributor

    sorry, I looked into it and reproduced it locally.

    in Q18, HAVING sum(l_quantity) > 300 filters the output of an aggregate, so the sum column has no min/max stats. before my PR, decimals weren't supported, so this filter got the default 20% (the ~120M rows in the 55.1 plan). now it goes through interval analysis, but with no bounds it estimates 100%, so 600M rows. that makes it look like the biggest input, and the semi join builds on the wrong side.

    I mentioned this "no stats means 100%" case in the PR description but didn't think about aggregate outputs. I reproduced it at SF1: the join flips and peak memory goes from ~430 MB to ~1.25 GB.

    for the re-land, I'll keep the default selectivity when a decimal column has no min/max stats, and add a Q18 plan test so this can't come back. i've tested that locally: Q18 gets its old plan back and the Q6 improvement stays.

  3. added a commit that references this issue on Nov 6, 2026
  4. asolimando commented on Nov 6, 2026

    @asolimando
    MemberAuthor

    sorry, I looked into it and reproduced it locally.

    in Q18, HAVING sum(l_quantity) > 300 filters the output of an aggregate, so the sum column has no min/max stats. before my PR, decimals weren't supported, so this filter got the default 20% (the ~120M rows in the 55.1 plan). now it goes through interval analysis, but with no bounds it estimates 100%, so 600M rows. that makes it look like the biggest input, and the semi join builds on the wrong side.

    I mentioned this "no stats means 100%" case in the PR description but didn't think about aggregate outputs. I reproduced it at SF1: the join flips and peak memory goes from ~430 MB to ~1.25 GB.

    for the re-land, I'll keep the default selectivity when a decimal column has no min/max stats, and add a Q18 plan test so this can't come back. i've tested that locally: Q18 gets its old plan back and the Q6 improvement stays.

    I took a cursory look when the error was reported and came to the same conclusion and what you propose is a reasonable fix for the degenerate cases with no bounds, happy to take a look when ready to get it to a reviewable state for maintainers to approve (FYI I will be mostly off next week with limited connectivity, fully back after that). Thanks for taking a look that quickly, @shrivasshankar!

  5. shrivasshankar commented on Nov 6, 2026

    @shrivasshankar
    Contributor

    sorry, I looked into it and reproduced it locally.
    in Q18, HAVING sum(l_quantity) > 300 filters the output of an aggregate, so the sum column has no min/max stats. before my PR, decimals weren't supported, so this filter got the default 20% (the ~120M rows in the 55.1 plan). now it goes through interval analysis, but with no bounds it estimates 100%, so 600M rows. that makes it look like the biggest input, and the semi join builds on the wrong side.
    I mentioned this "no stats means 100%" case in the PR description but didn't think about aggregate outputs. I reproduced it at SF1: the join flips and peak memory goes from ~430 MB to ~1.25 GB.
    for the re-land, I'll keep the default selectivity when a decimal column has no min/max stats, and add a Q18 plan test so this can't come back. i've tested that locally: Q18 gets its old plan back and the Q6 improvement stays.

    I took a cursory look when the error was reported and came to the same conclusion and what you propose is a reasonable fix for the degenerate cases with no bounds, happy to take a look when ready to get it to a reviewable state for maintainers to approve (FYI I will be mostly off next week with limited connectivity, fully back after that). Thanks for taking a look that quickly, @shrivasshankar!

    Thanks! It’s ready for review in #27148 no rush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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