Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions datafusion/physical-plan/benches/sort_merge_join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,21 @@ fn bench_smj(c: &mut Criterion) {
});
}

// N:1 Inner Join — 100K left, 10K right, 10K distinct keys
// Each buffered row matches the 10 streamed rows of its key, as when a fact
// table joins a dimension table on its primary key.
{
let left_batches = build_sorted_batches(100_000, 10_000, &s);
let right_batches = build_sorted_batches(10_000, 10_000, &s);
group.bench_function(BenchmarkId::new("inner_10to1", 100_000), |b| {
b.iter(|| {
let left = make_exec(&left_batches, &s);
let right = make_exec(&right_batches, &s);
do_join(left, right, datafusion_common::JoinType::Inner, &rt)
})
});
}

// 1:10 Inner Join — 100K left, 100K right, 10K distinct keys
{
let n = 100_000;
Expand Down Expand Up @@ -337,22 +352,32 @@ fn bench_smj(c: &mut Criterion) {
let keys = 20;
let left_batches = build_sorted_batches(keys * 100, keys, &s);
let right_batches = build_sorted_batches(keys * 1000, keys, &s);
group.bench_function(
BenchmarkId::new("inner_1to1000_selective_filtered", keys * 1000),
|b| {
// The same join as a Left join, which also emits the first streamed row
// of each key, whose pairs all fail, joined to NULLs.
for (name, join_type) in [
(
"inner_1to1000_selective_filtered",
datafusion_common::JoinType::Inner,
),
(
"left_1to1000_selective_filtered",
datafusion_common::JoinType::Left,
),
] {
group.bench_function(BenchmarkId::new(name, keys * 1000), |b| {
b.iter(|| {
let left = make_exec(&left_batches, &s);
let right = make_exec(&right_batches, &s);
do_join_with_filter(
left,
right,
datafusion_common::JoinType::Inner,
join_type,
Some(data_filter(Operator::Gt)),
&rt,
)
})
},
);
});
}
}

// Left Join — 100K each, ~5% unmatched on left
Expand Down
Loading