Skip to content

Apache DataFusion SQL Query Engine

bench: add ASOF join benchmark with a large unfiltered right input (#26483)

Kristoffer Vestergård Johansson6e8372f43a2c
diff --git a/benchmarks/sql_benchmarks/asof_join/asof_join.suite b/benchmarks/sql_benchmarks/asof_join/asof_join.suite
index f3d1ec19fc..1ff367bab6 100644
--- a/benchmarks/sql_benchmarks/asof_join/asof_join.suite
+++ b/benchmarks/sql_benchmarks/asof_join/asof_join.suite
@@ -33,3 +33,7 @@ description = "Run the equality-key filter ASOF join query."
[[examples]]
command = "cargo run --release --bin benchmark_runner -- asof_join --query 10"
description = "Run the compound equality-key filter ASOF join query."
+
+[[examples]]
+command = "cargo run --release --bin benchmark_runner -- asof_join --query 11"
+description = "Run the large unfiltered right-input ASOF join query."
diff --git a/benchmarks/sql_benchmarks/asof_join/benchmarks/q11.benchmark b/benchmarks/sql_benchmarks/asof_join/benchmarks/q11.benchmark
new file mode 100644
index 0000000000..35e9dddd2b
--- /dev/null
+++ b/benchmarks/sql_benchmarks/asof_join/benchmarks/q11.benchmark
@@ -0,0 +1,26 @@
+name Q11
+group asof_join
+
+expect_plan AsOfJoinExec
+
+run
+-- Left: 1M rows; right: 20M rows; 10K balanced equality groups; integer payloads.
+-- Both sides cover the same time range and the right input is unfiltered, so the
+-- whole right input is collected and scanned by every left partition.
+-- Inputs are not ordered by (key, ts), so required ordering is included.
+WITH left_input AS (
+ SELECT value % 10000 AS key,
+ (value / 10000) * 20 + 1 AS ts,
+ value AS payload
+ FROM range(1000000)
+),
+right_input AS (
+ SELECT value % 10000 AS key,
+ value / 10000 AS ts,
+ value AS payload
+ FROM range(20000000)
+)
+SELECT l.key, l.ts, l.payload, r.payload AS right_payload
+FROM left_input l
+ASOF JOIN right_input r MATCH_CONDITION (l.ts >= r.ts)
+ON l.key = r.key;