Repository navigation
Conversation
Contributor
Author
|
Evaluating TPC-DS tests to show the overall effect - wait for the results to get ready for review |
There was a problem hiding this comment.
🟡 Changes recommended
Unmapped scan-key attributes can cause partition scans to discard valid join matches, and runtime filters published after a partition opens never reach its active child.
4 open issues
What changed in this PR
This PR extends runtime Bloom filtering with adaptive probing and rejection-rate ordering in sequential scans and PAX storage, aiming to reduce overhead from ineffective filters.
Changes:
- Adds sampling-based probe disabling and filter ranking.
- Integrates adaptive filtering into PAX row reads and moves dynamic-partition filtering into child scans.
- Adds regression and unit coverage for filtering, ordering, and partition scans.
| File | Description |
|---|---|
src/test/modules/test_bloomfilter/test_bloomfilter.c |
Tests probe disabling and sequential-scan ordering. |
src/test/modules/test_bloomfilter/sql/test_bloomfilter.sql |
Invokes the adaptive-probing test. |
src/test/modules/test_bloomfilter/expected/test_bloomfilter.out |
Updates expected test output. |
src/include/nodes/execnodes.h |
Adds sequential-scan sampling state. |
src/include/lib/bloomfilter.h |
Exposes adaptive probe APIs. |
src/include/executor/nodeSeqscan.h |
Updates the filtering function signature. |
src/backend/lib/bloomfilter.c |
Implements probe sampling, disabling, and ranking. |
src/backend/executor/nodeSeqscan.c |
Applies adaptive probes and orders filters. |
src/backend/executor/nodeHashjoin.c |
Uses relation attribute numbers for dynamic-scan filters. |
src/backend/executor/nodeDynamicSeqscan.c |
Attaches filters to child scans and aggregates statistics. |
contrib/pax_storage/src/test/regress/sql/gp_runtime_filter.sql |
Adds join and partition pushdown scenarios. |
contrib/pax_storage/src/test/regress/expected/gp_runtime_filter.out |
Records expected plans and filtering statistics. |
contrib/pax_storage/src/cpp/storage/orc/orc_group.cc |
Adjusts null-aware column value retrieval. |
contrib/pax_storage/src/cpp/storage/micro_partition_row_filter_reader.h |
Declares sampling and filter-evaluation helpers. |
contrib/pax_storage/src/cpp/storage/micro_partition_row_filter_reader.cc |
Evaluates Bloom and expression filters with sampling. |
contrib/pax_storage/src/cpp/storage/filter/pax_sparse_pg_path.cc |
Updates comments about filter handling. |
contrib/pax_storage/src/cpp/storage/filter/pax_row_filter.h |
Adds unified filter nodes and sampling state. |
contrib/pax_storage/src/cpp/storage/filter/pax_row_filter.cc |
Registers runtime filters and sorts sampled nodes. |
contrib/pax_storage/src/cpp/storage/filter/pax_filter.h |
Extends row-filter initialization parameters. |
contrib/pax_storage/src/cpp/storage/filter/pax_filter.cc |
Forwards scan keys to row-filter initialization. |
contrib/pax_storage/src/cpp/storage/filter/pax_filter_test.cc |
Tests sampled filter ordering. |
contrib/pax_storage/src/cpp/comm/cbdb_api.h |
Exposes Bloom APIs to PAX code. |
contrib/pax_storage/src/cpp/access/pax_scanner.cc |
Supplies scan keys when creating row filters. |
Review effort: Balanced
leborchuk
force-pushed
the
adaptive-bloom-probing
branch
8 times, most recently
from
November 25, 2026 13:11
8595c05 to
58a2656
Compare
This optimization pushes down Bloom Filter conditions for runtime filters to the Pax Table AM layer. By applying the filter earlier than the SeqNext() function, it eliminates the overhead of converting data from columnar format to TableTupleSlot, resulting in faster query execution (cherry picked from commit e0abc24)
after calculating the null_counts array in advance, there is no need to call GetColumnDatum to continue updating null_counts. We can directly read the datum. (cherry picked from commit 6bc5d05)
Runtime filter pushdown hashes a key as the bytes of its Datum and compares the min/max range as int64. Only the low bytes of a narrow Datum carry the value: heap tuples sign-extend an int2 or int4, AOCO zero-extends it. A negative key could therefore hash differently on the build and the probe side and be dropped by the Bloom filter, and a zero-extended build key became a large positive number in the min/max range pushed into the table AM, so PAX could skip groups holding rows that join. Normalize narrow keys to one canonical form on both sides: the value sign-extended to int64. The same value then hashes the same whatever produced it, equal integers of different widths hash the same, which matters because int4 = int8 is accepted, and the range is taken from the canonical value. gp_enable_runtime_filter's RuntimeFilter node has the same problem: it puts raw integer Datums from the Hash node into its Bloom filter and probes it with the outer side's. It now records each key's width and normalizes both sides the same way. So does PAX's row filter, which probes the Bloom filters it was handed with the values it reads. test_bloomfilter checks the canonical form. PAX's gp_runtime_filter test joins negative int4 and int8 keys from an AOCO build side, co-located with the PAX probe so the Hash node sees AOCO's Datums, and compares the result multiset with pushdown on and off, then checks the RuntimeFilter node on the same join. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leborchuk
force-pushed
the
adaptive-bloom-probing
branch
from
November 25, 2026 14:23
58a2656 to
0c6d41b
Compare
leborchuk
force-pushed
the
adaptive-bloom-probing
branch
from
November 25, 2026 15:00
0c6d41b to
c496995
Compare
A table AM that takes runtime filter keys keeps copies of them: PAX turns the min/max range keys into its sparse filter and the Bloom keys into its row filter, and then turns executor-side checking off. When the hash join above is rescanned and rebuilds its hash table, ResetRuntimeFilter drops the old filters and builds new ones, but table_rescan() hands the AM no new keys and PAX's rescan ignores them. The scan then kept filtering with the previous build's keys, losing rows that join with the new one. ExecReScanSeqScan() now ends a scan that handed runtime filters to the table AM, turns executor-side checking back on, and lets the next SeqNext() begin a new scan with the current filters. Scans that did not hand filters to the AM rescan as before. Filters that arrive after the scan has started, because the join fetched an outer tuple before building its hash table, cannot reach the AM any more. Where the AM took the earlier filters and turned executor-side checking off, PushdownRuntimeFilter() now leaves those with the AM and checks only the new ones at the executor. PAX's gp_runtime_filter test runs a LATERAL nested loop whose hash table is rebuilt from a different set of keys on every iteration, checks that the plan has that shape, and compares the result multiset with pushdown on and off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FindTargetNodes() walks down a hash join's outer side through other hash joins to find the scan to filter, without looking at their join types. Below the outer side of a right or full join, a row the filter drops does not vanish: its partner comes out NULL-extended instead. A NULL-tolerant condition above then matches it. ORCA plans IS NOT DISTINCT FROM with a plain = in the hash clauses and the null test in hashqualclauses, so such a join is eligible for a runtime filter, and the query returned NULL-extended rows that should not exist. Only descend through joins whose output carries their outer rows' values unchanged: inner, left, semi and anti joins. gp_runtime_filter covers the IS NOT DISTINCT FROM case with ORCA. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sample non-null runtime Bloom probes and stop probing filters with low rejection rates. Rank sampled scan keys by their rejection rate and reuse PAX row-filter ordering and short-circuiting. Cover the cutoff and ordering in the backend and PAX tests.
A runtime Bloom filter that rejected too few keys in its first sample was disabled for good. When a table is loaded in key order, the first rows can all pass a filter that rejects most of the rest, and the filter is then lost for the whole scan. bloom_runtime_probe() now counts probes in windows of 1024. A window that rejects fewer than gp_runtime_filter_min_reject_pct percent (new developer GUC, default 5, 0 keeps filters on) disables the filter; bloom_runtime_probe_skip() lets rows pass and starts a new window after 1024 skipped rows, doubling the gap while the filter stays ineffective, up to 64M rows. A window that rejects enough turns the filter back on and resets the gap. An enabled filter is re-evaluated every window as well. Ranking uses the last full window. A useless filter now costs a few thousand probes per hundred million rows. test_bloomfilter covers the re-check schedule and the 0% threshold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A hash join whose probe scan runs in the join's own slice needs no exchange: each segment's Hash node already receives every key its scanned rows can match. The coordinator skips the exchange for such joins, and every segment re-runs the same eligibility check (AnserInplaceEligible) on the plan at executor start, wraps the Hash node's child to collect normalized keys into a Bloom filter, and installs an Anser scan qual on the probe SeqScan. The filter holds only the keys left after the build side's joins and predicates, the scan never waits for it, and probes go through the adaptive bloom_runtime_probe_skip. No core plan node, flag or EXPLAIN change is needed, and nothing depends on gp_enable_runtime_filter_pushdown: every key type Anser accepts works. anser.runtime_filter and anser.runtime_filter_inplace are synced to segments so both sides decide alike. Full-width keys of exchanged filters fall back to the Anser qual when core's scan-key path is off. Consumers probe adaptively too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A SeqScan handed its runtime filters to the table AM, and checked them itself, only while gp_enable_runtime_filter_pushdown was on. That GUC decides whether hash joins create runtime filters; the scan does not need to ask it again. Filters only reach a scan because something put them there, and an extension that does so -- Anser hands its exchanged Bloom filters to the probe scan -- had them ignored with the GUC off. The scan now applies whatever filters it has, outside MPP parallel mode as before, passing them to an AM that supports runtime filters, such as PAX, when the scan starts. With the GUC off and no extension adding filters, the list is empty and nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An exchanged filter reached a PAX probe only as an Anser-owned scan qual, which PAX drops when its row filter rebuilds the scan's qual from the plan, so on PAX the consumer had to probe every row itself. Hand the filter to the scan as an SK_BLOOM_FILTER key instead, for keys of every width: PAX then checks it in its row filter before it loads the other columns, and other scans check it in SeqNext. The scan takes keys without gp_enable_runtime_filter_pushdown now. Core and PAX probe such a key in core's canonical form, sign-extended to 64 bits, so Anser now hashes narrow keys that way on both sides too (it used to zero-extend them); the two forms are equally storage-independent. The Anser qual remains for scans that cannot take a key -- MPP parallel mode, or an AM that took earlier keys and has started -- and the consumer still probes by itself on AOCO and on AMs that take runtime filters. anser_runtime_filter checks that negative keys are pruned at the scan on heap and AOCO probes with core pushdown on and off, and, where PAX is installed, that a PAX probe takes the filter with and without its row filter and returns the same rows, exchanged or in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leborchuk
force-pushed
the
adaptive-bloom-probing
branch
from
November 25, 2026 15:59
c496995 to
09e4482
Compare
Mix matching and unmatched keys and disable adaptive backoff while asserting that both PAX paths reject rows. Adaptive probing is covered separately by the weak-filter fixture.
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.


This is a extension of the original work #1333
With the adaptation to the anser #1942
Here I try to make bloom filters more effective. Also I addressed here all performance findings from #1942
In the overall, changes could be grouped in 3 categories:
Extend gp_enable_runtime_filter and make it enabled internally by Anser, not only by user. Add support not only int4/int8 Datum types, since we already support a more wide range of data types in Anser, it's safe to support it here too.
These is useful not only for co-located joins but for broadcast data too. if we broacast table, no need to use Anser and coordinator to create bloom filters. All data was broadcasted to each host, and each host could create bloom filters and use them for filter out rows.
That was the main reason for performance loss in 5 queries TPC-DS.
Fix found issues in PAX (here also was issues with hashes of int4 values). The key decision - I prefer bloom filters over other quals, so at first we try to filter out using bloom filters and only then the ordinary quals.
Sort bloom filters by reject rate (first with the highest reject rate). And reject bloom filters if first 1024 keys show we filter out nothing. Use the same approach for PAX, NodeScan and NodeDynamicScan.
The TPC-DS SF=1000 results:
the raw results for the `anser.runtime_filter = on`
``` postgres=# select a.query_id, round(b.duration_ms / a.duration_ms - 1, 2) as diff, b.duration_ms from tpcds.bench_results a join tpcds.bench_results b on a.query_id = b.query_id and a.run_ts < b.run_ts where a.run_ts = '2026-11-23 21:24:15.294009+00' and b.run_ts = '2026-11-24 07:25:16.002593+00' order by 2 asc; query_id | diff | duration_ms ----------+-------+------------- 16 | -0.51 | 68358.47 78 | -0.47 | 774264.69 84 | -0.43 | 4316.19 25 | -0.43 | 130575.32 21 | -0.41 | 12876.29 55 | -0.41 | 52140.57 17 | -0.41 | 131627.19 54 | -0.40 | 88766.09 63 | -0.39 | 60346.59 53 | -0.39 | 60420.71 3 | -0.39 | 51261.28 90 | -0.38 | 12757.04 88 | -0.38 | 149636.71 20 | -0.38 | 24722.33 52 | -0.37 | 51645.27 6 | -0.36 | 50497.96 91 | -0.36 | 3660.16 89 | -0.36 | 75227.27 12 | -0.35 | 13652.86 42 | -0.35 | 52942.02 96 | -0.35 | 52172.84 58 | -0.35 | 53121.43 32 | -0.35 | 51100.94 10 | -0.34 | 89172.40 34 | -0.34 | 73837.07 82 | -0.34 | 47574.24 92 | -0.34 | 27733.83 37 | -0.34 | 30103.53 69 | -0.33 | 86246.18 8 | -0.33 | 59101.20 19 | -0.32 | 70635.42 73 | -0.32 | 68475.23 83 | -0.31 | 5859.77 61 | -0.30 | 79844.40 98 | -0.30 | 59274.61 46 | -0.30 | 106890.59 26 | -0.28 | 50163.32 15 | -0.28 | 33527.94 40 | -0.26 | 43161.90 68 | -0.26 | 113276.84 7 | -0.26 | 106419.02 45 | -0.26 | 21919.40 43 | -0.25 | 89715.45 35 | -0.21 | 131100.96 29 | -0.21 | 172010.26 79 | -0.16 | 145397.31 94 | -0.14 | 74176.78 65 | -0.13 | 334617.63 72 | -0.13 | 157791.14 1 | -0.12 | 30232.82 23 | -0.10 | 3212247.98 62 | -0.10 | 53883.14 80 | -0.09 | 149099.40 51 | -0.09 | 258176.05 97 | -0.09 | 309940.67 11 | -0.08 | 575816.05 99 | -0.07 | 110871.92 4 | -0.07 | 1001603.09 48 | -0.06 | 155293.00 41 | -0.05 | 64.47 85 | -0.05 | 42595.35 71 | -0.04 | 157830.56 75 | -0.04 | 336295.24 22 | -0.03 | 68814.35 39 | -0.02 | 49842.74 30 | -0.02 | 11107.57 74 | -0.02 | 386683.26 95 | -0.02 | 2908856.34 57 | -0.02 | 133961.24 13 | -0.02 | 169242.01 33 | -0.01 | 94382.05 81 | -0.01 | 12671.53 66 | -0.01 | 76557.58 44 | -0.01 | 59439.00 38 | -0.01 | 280206.00 86 | 0.00 | 51878.72 49 | 0.00 | 148558.50 24 | 0.00 | 549241.92 36 | 0.00 | 179832.82 28 | 0.00 | 155268.36 5 | 0.00 | 121843.96 70 | 0.00 | 263265.49 77 | 0.00 | 104146.85 9 | 0.01 | 269690.83 64 | 0.01 | 365545.90 76 | 0.01 | 97300.32 56 | 0.01 | 92741.85 31 | 0.02 | 136193.25 27 | 0.02 | 143671.06 87 | 0.02 | 292207.08 50 | 0.03 | 274036.69 2 | 0.04 | 241207.47 60 | 0.04 | 100121.19 14 | 0.06 | 719112.95 67 | 0.10 | 3086488.73 47 | 0.17 | 414194.20 93 | 0.31 | 406979.23 59 | 0.37 | 1867902.10 18 | 0.47 | 150138.80 ```gp_enable_runtime_filter_pushdownimprove performance some queries but have limited scope to the overall improvements are indistinguishable from the noise of cluster performance while spilling a lot of dataanser.runtime_filterimprove performance for some queries and degrade for the others.And only when I combined two approaches the overall increasing is stable reproducible. That also answers #1942 proposals
We do not need it at all since in Q58 we use broadcast. And broadcast could be used to create bloom filters locally.