Headline vs detail. FINDINGS row 47 leads with the order effect: 3,020,210 intermediate tuples in the bad join order against 23,246 in the good one (130×) for a 20,210-row answer. After a full Yannakakis reduction (1.07 × N hash operations) the bad order emits 60,504 tuples, no join exceeds the output, and the gap falls to 2.62×; on an already-good order the reduction is pure overhead.
cargo run --release --bin semijoin_bench. Seeded generator (gen.rs,
GraphParams::LANE1, seed 47): every count below reproduces exactly on any
machine. Timings are best of 3 in one run; other agents were benchmarking on
the same machine, so sysctl -n vm.loadavg was recorded with each run.
Hand predictions that check out: 1,000,000 and 2,000,000 are exact
(5 likes per person, 2 tags per post). knows′ ≈ 200,000 × (1 − (1 −
(1 − 0.99²))⁵) = 19,100 (measured 19,340). has_tag after the backward pass
≈ 1,000 × (1 − e⁻²) = 865 (measured 868).
Negative result: on the good order the reduction costs 428,303 hash
operations to save 132 intermediates. It is insurance, not a speed-up.
Timing surprise: the good order is slower (6.94 ms) than reduction +
bad order (1.50 + 0.52 ms), because its left-deep shape builds hash tables
on knows and likes (400,000 build rows). Intermediate counts are not the
whole cost of a plan.
Register-blocked = DuckDB v2.0.0’s layout (d54cbbe3df: 4 bits in one 64-bit
word, sized at ≥ 12 bits/key rounded to a power of two) with this crate’s hash.
These sizes are what DuckDB allocates for an exact build count; its Seal step
folds a filter only when the key set is sparser than that sizing assumes, which
none of these three rows is (folded density⁴ 2.2%, 4.4%, 1.0% against its
0.646% target). An
independent Python simulation of the same layout while writing the DuckDB
guide gave 0.0045 at 1,000 keys and 0.0091 at 10,000 — same shape.
lane 2, 8 bits/key: total survivors (exact 22,243)
lane 2, 8 bits/key: which relation carries most of the inherited rows?
lane 2, 16 bits/key: bad-order intermediates vs exact 60,504
lane 2: does a filter’s per-key FPR match (1 − e^(−kn/m))^k?
lane 3, bad order, into lower builds: intermediates
lane 3, bad order, probe spine only: intermediates
lane 3, good order: rows put into hash tables
exercise 2: inherited rows at 8 bits/key with the register-blocked filter
Author's expectations while designing the lanes (written down here after the reference ran — hindsight is possible, so weigh them accordingly)
Lane 3, bad order, into lower builds: the cascade leaves exactly the forward-pass sizes, so 60,504 intermediates — the same as the full reduction. (Held.)
Lane 3, bad order, probe spine only: essentially no help, since the bitmap that can reach knows is built from unfiltered likes. (Held: 3,020,210.)
Lane 3, good order: the top build (knows) is unfiltered, ~400,000 rows built. (Held: 386,439 and 400,000.)
Lane 2: no numeric expectation was formed for the inherited column; that it is 5× the filters’ own false positives at 8 bits/key was the surprise of the topic.
From reference implementations of transfer::bloom_transfer and
bitmap::bitmap_cascade written to the contracts in the stub doc comments,
run against lane 1’s data (load 4.39 at start), all 15 tests green, then
removed. Counts are exact; your implementation must reproduce them.
False positives are per key, rows inherit them. rare_tag → has_tag let
6 of 990 absent tags through; each tag has ~100 posts, so 606 rows. The
first draft of the FPR test measured per row and failed for exactly this
reason (10 keys, 90 distinct negatives in the small test graph); the
contract now measures per distinct key.
10-key filters round 80 bits up to 128, so their theory column (0.0027) is
lower than the 8-bits/key nominal 0.0215; 6 FP keys of 990 is 0.6% — noisy
at that sample size.
PT’s §3.5 model predicts knows’s own false positives as 180,660 × 0.0215 =
3,884; measured 3,340. The model has no term for the 28,648 inherited rows.
Bad + into lower builds = lane 1’s after-forward sizes exactly; its 60,504
intermediates equal the full two-pass reduction’s — the CIDR’26 §3.3
one-pass claim, reproduced. has_tag stays at 1,000 (not 868) and it does
not matter: the 132 unliked posts are never probed.
Probe spine only gives the bad order nothing; the bitmap that does reach
knows (on b) was built from unfiltered likes.
RPT+ (VLDB’26). Geomean over DuckDB v1.3.0: 1.47× JOB, 1.28× SQLStorm,
1.17× TPC-H, 1.01× Appian (abstract, §1, §9, Figure 11). SQLStorm: 18,251
queries, 13,308 finish, 2,837 fail, 2,106 time out (§6.1). RPT 555 + 3,185
= 28.1% below 0.9×; RPT+ 24 + 247 = 2.1% (Tables 1–2). Worst RPT+ query
13615 at 0.37× (§6.6.3). Constants: γ = 100K, τ_sel = 0.35, τ_prog = 0.6,
M_avail = 64 GB, τ_stop = 0.9 (§5.4); Figure 9 and §5.3 use 0.95 instead —
minor inconsistency. CSBF 20 bits/key, 7 hashes, 2.48 cycles/tuple, FPR
6.1 × 10⁻⁵ (§5.4). Min–max inflation E[range] ≈ n − 2/p (§4.2); JOB 07c
BF 6 holds 14 vs 378 items at 24 vs 16 bits/key, ~4× (§6.6.2). “Up to
500×” (§6.1) is prose about Figure 10; Table 2’s >100× bucket is 12
queries averaging 226.29×.
SQL Server bitmaps (CIDR’26). TPC-H SF100: 7 of 22 queries > 2× (Q2
3.47, Q5 2.33, Q7 3.00, Q8 2.86, Q17 2.55, Q20 2.01, Q21 2.36); 12 acyclic
queries instance-optimal (prose — Table 1’s check marks do not survive text
extraction); 5 queries with optimizer slowdown (Q5, Q7, Q8, Q18, Q19).
Pre-filter gaps: Q3 5.23% vs Yannakakis 1.25%, Q8 1.92% vs 0.16%
(Table 1). Q12: 15 M orders → 2.96 M vs 2.92 M perfect (§3.1). Q3
estimate with bitmap contexts 3.3 M vs 323 M (§4.1). Telemetry: 7% of join
queries > 8-way (up to 1,000 tables), 15% hybrid join types (§6).
Discrepancies: “deployed since 2012” (§1) vs “shipped in SQL Server 2014”
(acknowledgments); rowgroups “~900 rows” (§3.1, probably a lost K — not
used).
Predicate Transfer (CIDR’24). PredTrans vs NoPredTrans 4.1× / 4.0×,
BloomJoin 3.3× / 3.2×, Yannakakis 4.2× / 4.8× at SF1 / SF10 (§4.2); 15 of
20 join queries improve; Q2 47×/44× (SF1) and 63×/61× (SF10) over
NoPredTrans/BloomJoin. Q5: join inputs 98%/96%/64% smaller than
NoPredTrans/BloomJoin/Yannakakis at SF1, 98/92/67% at SF10 (Tables 1–2);
transfer phase 13×/16× faster than the semi-join phase; join-order spread
up to 12% vs up to 45× (Figure 6). Does not hold as stated: the
introduction’s “3.3× (up to 61×) … Yannakakis … 4.8× (up to 47×)” mixes
an SF1 average (3.3×) with an SF10 one (4.8×), and the only 47× in §4.2 is
Q2 against NoPredTrans at SF1, not against Yannakakis.
IN predicates (CIDR’26). Wrong results: ClickHouse 25.8, Hyper 9.1.0,
DuckDB 1.3.0, Snowflake 9.21.0, Redshift 1.0.118447, Firebolt Core 4.23.5
(§1). Right mark join 9 ms vs left 15 ms at 10⁶ × 10⁶ (4.5 / 7.5 ns per
tuple), break-even slope ≈ 1.3 (§7, Figure 10).
Yannakakis (VLDB’81). Not obtained: the VLDB 1981 archive returned
HTTP 403 and no other copy was found. Its guarantees are quoted from the
three papers above (PT §2.2, RPT+ §2.1, CIDR’26 §2.1) and checked by this
crate’s tests; no number is attributed to it.
Topic 10’s §4 (RPT+) and §5 (SQL Server bitmaps) and topic 11’s §5 (the IN
paper) are the one-paragraph versions of guides 2–4 here; both checked claims
there (1.47/1.28/1.17/1.01×; 7 of 22 > 2×, 12 instance-optimal) match.
Topic 44’s Free Join chapter places Yannakakis as the acyclic case; lane
1’s chain is the simplest instance.
Topic 11’s IN-predicate paragraph and guide 4 here are the same paper; guide
4 adds the algorithm.
Does DuckDB’s pause back off as traced? Step 6 of
reading-duckdb-join-filters.md says a filter that stays unselective is
evaluated for 6 vectors, skipped for 4, evaluated for 6, skipped for 14, and
so on; confirm with a DuckDB build and a probe column whose first six
vectors all match.
Does DataFusion populate a dynamic filter routed into a lower join’s build
side before that build scans? Routing allows it (exec.rs:1983-1995, key transfer :1970-1988);
execution order was not traced.
How large is the inherited term on a star schema, where there is no second
hop?