Repository navigation
feat: re-land Decimal filter selectivity estimation without the TPC-H Q18 regression - #27148
shrivasshankar wants to merge 5 commits into
Conversation
Re-applies apache#25790, which was reverted in apache#27145 because of a TPC-H Q18 regression (apache#27108). The next commit fixes the regression.
… stats Interval analysis estimates a selectivity of 1.0 for a column without bounds. In TPC-H Q18, `HAVING sum(l_quantity) > 300` filters an aggregate output, which has no min/max stats, so apache#25790 changed its estimate from the default 20% to 100% and the semi join built its hash table on the wrong side. Decimal predicates now use interval analysis only when every decimal column in them has min and max stats. Otherwise they keep the default selectivity, as before apache#25790.
|
cc @asolimando @devanbenz @kosiew, this re-lands apache/datafusion#25790 · feat: estimate Decimal filter… with the Q18 fix. The Q18 plan check is in filter_statistics_decimal.slt. |
Interval analysis estimates an equality from the number of values in the column's range, and for a decimal that counts every step of its scale. In TPC-DS, `ca_gmt_offset = -5` on a DECIMAL(5, 2) column holding whole numbers from -10 to -5 was estimated at 100 rows instead of 18,246, which flipped the semi joins in q33, q56, q60, q61 and q91. Decimal equality filters now keep the estimate they had before apache#25790. Range filters on decimal columns still use interval analysis.
|
Update: while checking TPC-DS, I found that = filters on decimal columns were also badly underestimated (100 rows instead of 18,246 for ca_gmt_offset = -5), which flipped 5 TPC-DS plans. I added a commit so decimal equality keeps its old estimate. All TPC-H and TPC-DS plans now match main. |
|
@kosiew @xudong963 Are you able to kick off the automated benchmarks? We should run all available benchmarks both with pushdown filtering on and off. If we can think of any other configurations which may be impacted by this as well please run those as well.
Better estimates is nice! But also, it would be cool to see metrics associated with performance goodness. If you have them please add them to the PR description :) |
Thanks! With this PR, every TPC-H (SF1, SF10) and TPC-DS (SF1) plan is identical to main, with pushdown_filters both on and off, so I wouldn’t expect runtime changes on those benchmarks. The gain for now is in the estimates themselves. For example, the Q6-style filter goes from 1.2M estimated rows to 111K (actual 114K). I’ll add the benchmark results to the description once they’ve run. |
Which issue does this PR close?
Rationale for this change
#25790 gave two kinds of decimal filters bad estimates:
HAVING sum(l_quantity) > 300: estimated at100% of rows instead of 20%, which flipped the Q18 semi join.
ca_gmt_offset = -5onDECIMAL(5, 2): intervalanalysis counts every 0.01 step, so it estimated 100 rows instead of 18,246.
What changes are included in this PR?
feat: estimate Decimal filter selectivity with interval analysis #25790. Range filters on decimals still use interval analysis.
What is the testing strategy for this PR?
filter_statistics_decimal.slt.feat: estimate Decimal filter selectivity with interval analysis #25790 alone, TPC-H Q18 and 7 TPC-DS plans changed.
(actual 114,160) vs 1,200,243 on main.
Are there any user-facing changes?
Better estimates for range filters on decimal columns with min/max stats. One
new public function,
check_statistics_support.