Skip to content

Commit 2e5933f

Browse files
committed
Add benchamrks for hashjoin candidate equality filtering
1 parent 1955d5a commit 2e5933f

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name Q24
2+
group hj
3+
4+
init sql_benchmarks/hj/init/set_config_no_stats.sql
5+
6+
load sql_benchmarks/hj/init/load.sql
7+
8+
assert I
9+
SELECT count(*) > 0 FROM lineitem
10+
----
11+
true
12+
13+
expect_plan HashJoinExec
14+
15+
run
16+
-- Q24: single-hot-bucket long string-key inner join.
17+
-- Build rows all share one long string key, so each matching probe row fans
18+
-- out to the whole build side. count(*) focuses the benchmark on hash match
19+
-- and equality filtering without buffering joined rows.
20+
-- Thresholds zeroed to force Partitioned mode (simulates absent row-count stats).
21+
SELECT count(*)
22+
FROM (
23+
SELECT 'single_hot_bucket_string_join_key' as k
24+
FROM supplier
25+
WHERE s_suppkey <= 3000
26+
) s
27+
JOIN (
28+
SELECT 'single_hot_bucket_string_join_key' as k
29+
FROM lineitem
30+
WHERE l_orderkey % 3000 = 0
31+
) l ON s.k = l.k;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name Q25
2+
group hj
3+
4+
init sql_benchmarks/hj/init/set_config_no_stats.sql
5+
6+
load sql_benchmarks/hj/init/load.sql
7+
8+
assert I
9+
SELECT count(*) > 0 FROM lineitem
10+
----
11+
true
12+
13+
expect_plan HashJoinExec
14+
15+
run
16+
-- Q25: skewed high-fanout multi-column string-key inner join.
17+
-- This tracks candidate-pair filtering for composite keys: the first key is
18+
-- skewed and the second long string key must also be checked before emitting
19+
-- each match. count(*) isolates the match path.
20+
-- Thresholds zeroed to force Partitioned mode (simulates absent row-count stats).
21+
SELECT count(*)
22+
FROM (
23+
SELECT CAST((s_suppkey % 256) + 1 AS INT) as k1,
24+
'multi_column_high_fanout_key' as k2
25+
FROM supplier
26+
WHERE s_suppkey <= 20000
27+
) s
28+
JOIN (
29+
SELECT CAST(1 AS INT) as k1,
30+
'multi_column_high_fanout_key' as k2
31+
FROM lineitem
32+
WHERE l_orderkey % 250 = 0
33+
) l ON s.k1 = l.k1 AND s.k2 = l.k2;

benchmarks/src/hj.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,52 @@ const HASH_QUERIES: &[HashJoinQuery] = &[
472472
probe_size: "2.3M_long_keys_count",
473473
isolate_partitioned_join: true,
474474
},
475+
// Q24: single-hot-bucket long string-key inner join.
476+
// Build rows all share one long string key, so each matching probe row fans
477+
// out to the whole build side. The output is counted to focus on the hash
478+
// match/equality path without buffering the joined rows.
479+
HashJoinQuery {
480+
sql: r###"SELECT count(*)
481+
FROM (
482+
SELECT 'single_hot_bucket_string_join_key' as k
483+
FROM supplier
484+
WHERE s_suppkey <= 3000
485+
) s
486+
JOIN (
487+
SELECT 'single_hot_bucket_string_join_key' as k
488+
FROM lineitem
489+
WHERE l_orderkey % 3000 = 0
490+
) l ON s.k = l.k"###,
491+
density: 1.0,
492+
prob_hit: 1.0,
493+
build_size: "3K_(single_hot_bucket)",
494+
probe_size: "20K_long_keys_count",
495+
isolate_partitioned_join: true,
496+
},
497+
// Q25: skewed high-fanout multi-column string-key inner join.
498+
// This tracks the same candidate-pair filtering path for composite join
499+
// keys, where the first key is skewed and the second long string key must
500+
// also be checked before emitting each match.
501+
HashJoinQuery {
502+
sql: r###"SELECT count(*)
503+
FROM (
504+
SELECT CAST((s_suppkey % 256) + 1 AS INT) as k1,
505+
'multi_column_high_fanout_key' as k2
506+
FROM supplier
507+
WHERE s_suppkey <= 20000
508+
) s
509+
JOIN (
510+
SELECT CAST(1 AS INT) as k1,
511+
'multi_column_high_fanout_key' as k2
512+
FROM lineitem
513+
WHERE l_orderkey % 250 = 0
514+
) l ON s.k1 = l.k1 AND s.k2 = l.k2"###,
515+
density: 1.0,
516+
prob_hit: 1.0,
517+
build_size: "20K_(fanout~78_multi_key)",
518+
probe_size: "240K_multi_key_count",
519+
isolate_partitioned_join: true,
520+
},
475521
];
476522

477523
impl RunOpt {

0 commit comments

Comments
 (0)