Repository navigation
feat: enable datafusion.optimizer.enable_window_topn by default - #27197
Conversation
|
run benchmark h2o_small_window_parquet |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_small_window_parquetResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_small_window_parquetCPU Details (lscpu)Details
Resource Usageh2o_small_window_parquet — base (merge-base)
h2o_small_window_parquet — branch
File an issue against this benchmark runner |
|
run benchmarks |
|
run benchmark h2o_small_parquet h2o_medium_parquet h2o_medium_window_parquet |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark clickbench_partitionedResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark tpcdsResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark tpchResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_medium_window_parquetResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_medium_parquetResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_small_parquetResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark tpchCPU Details (lscpu)Details
Resource Usagetpch — base (merge-base)
tpch — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_small_parquetCPU Details (lscpu)Details
Resource Usageh2o_small_parquet — base (merge-base)
h2o_small_parquet — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark tpcdsCPU Details (lscpu)Details
Resource Usagetpcds — base (merge-base)
tpcds — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_medium_parquetCPU Details (lscpu)Details
Resource Usageh2o_medium_parquet — base (merge-base)
h2o_medium_parquet — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark clickbench_partitionedCPU Details (lscpu)Details
Resource Usageclickbench_partitioned — base (merge-base)
clickbench_partitioned — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing window-topn-default-on (29ee2ad) to 4bf32cb (merge-base) diff Run configurationrun benchmark h2o_medium_window_parquetCPU Details (lscpu)Details
Resource Usageh2o_medium_window_parquet — base (merge-base)
h2o_medium_window_parquet — branch
File an issue against this benchmark runner |
alamb
left a comment
There was a problem hiding this comment.
thank you so much for this work @SubhamSinghal -- this is great
I did a final test locally just to give it a try
CREATE EXTERNAL TABLE hits STORED AS PARQUET
LOCATION 'benchmarks/data/hits_partitioned';Here is the query
SELECT count(*) FROM (
SELECT "RegionID", "EventTime", "WatchID",
ROW_NUMBER() OVER (PARTITION BY "RegionID" ORDER BY "EventTime" DESC) AS rn
FROM hits
) WHERE rn <= 3;Then enabled via
SET datafusion.optimizer.enable_window_topn = true;On main (before this PR): Elapsed 3.671 seconds.
With the flag: Elapsed 0.246 seconds. 😎
And the explain plan shows
| | ┌─────────────┴─────────────┐ |
| | │ PartitionedTopKExec │ |
| | │ -------------------- │ |
| | │ emit: │ |
| | │ [row_number() PARTITION BY│ |
| | │ [hits.RegionID] ORDER BY │ |
| | │ [hits.EventTime DESC │ |
| | │ NULLS FIRST] RANGE │ |
| | │ BETWEEN UNBOUNDED │ |
| | │ PRECEDING AND │ |
| | │ CURRENT ROW] │ |
| | │ │ |
| | │ fetch: 3 │ |
| | │ fn: row_number │ |
| | │ │ |
| | │ order: │ |
| | │ [EventTime@0 DESC] │ |
| | │ │ |
| | │ partition: │ |
| | │ [RegionID@1] │ |
| | └─────────────┬─────────────┘ |Also, it would be sweet if we got a writeup of this feature in time for datafusion-57
97a94cd to
2d15352
Compare
|
Resolved build failure. |
|
Thank you @SubhamSinghal -- this is epic |
Which issue does this PR close?
datafusion.optimizer.enable_window_topn) by default #24608.Rationale for this change
enable_window_topnhas been off since #21479 because of high-cardinality regressions against the sort plan. The work items in #24608 are now done:The h2o window benchmark's Top-N queries (
benchmarks/queries/h2o/window.sql, Q13–Q29, small dataset,J1_1e7_1e7_NA.parquet) are now faster with the flag on in every case, up to 100K partitions and including the heavy-ties variants.dfbench h2o --iterations 5, median,DATAFUSION_OPTIMIZER_ENABLE_WINDOW_TOPN=falsefor the baseline, same binary, Apple M4 Max:What changes are included in this PR?
enable_window_topndefaults totrue; its doc comment now lists ROW_NUMBER, RANK and DENSE_RANK and drops the high-cardinality warning.window_topn.sltrestores the setting withRESETinstead ofSET ... = false.configs.mdandinformation_schema.sltregenerated.window_sortedsettings comment no longer says the flag defaults to false (it still sets it explicitly).What is the testing strategy for this PR?
Existing coverage. With the flag on by default, the whole sqllogictest suite and
core_integrationpass with only theinformation_schema.sltdefault change;qualify.slt'srank <= 3/dense_rank <= 2cases now run throughPartitionedTopKExecand return the same results.window_topn.sltstill covers the disabled path explicitly.Are there any user-facing changes?
Yes. Top-K-per-partition queries (
rn <= K,rn < Kover ROW_NUMBER / RANK / DENSE_RANK) plan withPartitionedTopKExecinstead of a full sort, soEXPLAINoutput changes; results don't. Setdatafusion.optimizer.enable_window_topn = falseto get the old plan.