Repository navigation
Conversation
…_SHOW_STATS) in tpch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k-chunk decoding) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…MODE) and dynamic-only pushdown (DF_PUSHDOWN_MODE) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efault, composite-key join NDV Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…educe input <2x Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…izedCte (DF_AUTO_CTE) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an projects more other columns than filter columns Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… its selectivity (DF_LIKE_CHAR_SEL) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amic filters reach below the aggregate Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…true, single row filter, auto static pushdown, auto CTE, row-based build side, physical-core target_partitions) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cripts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Experimental. Not intended to be merged. This PR collects a set of experiments
toward #26169 so the results and code can be discussed in one place. Pieces that
hold up would be split into separate, focused PRs with tests.
Which issue does this PR close?
Rationale for this change
On TPC-H SF100 (Parquet, 16 cores / 32 threads, 125 GB RAM), DataFusion
maintakes134.1 s in total and Polars 2.2 (streaming engine) takes 58.5 s. Most of the gap
comes from a few queries (q2, q7, q9, q11, q15, q17, q18, q21).
This branch tests whether incremental changes to the existing planner, statistics,
and operators can close most of that gap. The aim was to stay within today's
architecture and avoid a rewrite.
Result: 63.8 s in total, 2.10x faster than
mainand within 9% of Polars. Thebranch is faster than Polars on 7 of the 22 queries.
Best of 3 runs. Both DataFusion builds use the LTO
releaseprofile. Each changebelow was measured on its own on the full suite and kept only if it helped.
benchmarks/polars-gap/REPORT.mdhas the step-by-step numbers, the profiles behindeach change, what was tried and dropped, and the remaining gaps.
What changes are included in this PR?
Each change has an environment variable that switches back to the old behavior, so
one binary can compare both. The last commit makes all of them the default.
target_partitionsdefaults to physical cores (Linux with SMT). Running 32partitions on 16 cores slows down cache-heavy operators. About 12% faster.
pushdown_filters = true, with all filter conditions combined into one ParquetRowFilter. A filter with no dynamic (join-generated) part is pushed into thereader only when the scan outputs more columns outside the filter than inside it.
Otherwise it stays in a
FilterExecand is still used for pruning. Dynamic joinfilters are always pushed. Together with item 3, about 30% faster.
arrow-rs: decode at most
batch_sizerows per mask chunk before filtering(
andygrove/arrow-rs@f27661c, applied through[patch.crates-io]). With a sparseselection, the reader used to decode hundreds of thousands of rows into one array
before filtering. This was the cause of the pushdown slowdowns in q6, q12 and q15.
Better statistics for choosing the hash join build side.
partsupp'stwo-column primary key).
q17 goes from 14.4 s to 2.5 s.
Partial aggregation stays small enough to fit in cache. The partial hash table
emits its groups and starts over at 4096 groups. If it is not at least halving its
input, it doubles the limit instead. q18 goes from 11.0 s to 5.0 s.
New logical rule
MaterializeCommonSubplans. A subplan that aggregates orjoins and appears more than once is computed once, using the existing
MaterializedCte. q15 goes from 5.9 s to 2.0 s.New logical rule
DeferAggregateJoinKeys. A join key that is an aggregateresult (q2's
ps_supplycost = min(ps_supplycost)) moves into the join filter. Theremaining keys' dynamic filter can then reach below the aggregate. q2 goes from
1.7 s to 0.59 s.
Join filters that keep more than 90% of rows switch themselves off after the
first 1M rows.
Benchmark tooling.
dfbench tpchcan write per-query flamegraphs(
DF_PPROF) and show plan statistics (DF_SHOW_STATS). Scripts and the reportare under
benchmarks/polars-gap/.What is the testing strategy for this PR?
There are no new tests yet. That work belongs in the follow-up PRs.
datafusion-datasource-parquetunit tests pass in every pushdown mode. The oneexception is a test that expects a non-dynamic filter to be pushed down, which the
new
automode declines on purpose.differences. The one exception is a row-order change in a
pipe_operator.sltquery that has no
ORDER BY.EXPLAIN-based expected outputs, which have not been updated.
Are there any user-facing changes?
Yes, but this PR is not meant to merge as is.
datafusion.execution.parquet.pushdown_filters = true, andtarget_partitionsequals physical cores on Linux.MaterializedCteExecforrepeated subplans, and different filter placement.
DF_*environment variables, forexperimentation only.
FilterExec::statistics_helperbecomespub(#[doc(hidden)]).AI usage disclosure
This work was done with Claude Code (Claude Opus) under my direction. Claude profiled
the queries, read plans, wrote the code and ran the benchmarks. I have not reviewed
the code. Treat it as unreviewed experimental output. Before any of it is split into
real PRs, I will review it, starting with the parts most likely to hide bugs:
ParquetSource::try_pushdown_filters;MaterializeCommonSubplans.The heuristics (10% string equality, 0.8 per LIKE character, 4096-group flush, 90%
filter cutoff) were tuned on TPC-H only and need validation on other workloads such
as ClickBench and TPC-DS.
🤖 Generated with Claude Code