Skip to content

Commit

Permalink
ds72-connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Jul 29, 2024
1 parent fe7b674 commit 766e5fa
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,14 @@ public Cost visitPhysicalHashJoin(

double leftRowCount = probeStats.getRowCount();
double rightRowCount = buildStats.getRowCount();
int leftConnectivity = computeConnectivity(physicalHashJoin.left(), context);
int rightConnectivity = computeConnectivity(physicalHashJoin.right(), context);

if ((long) leftRowCount == (long) rightRowCount) {
// reorder by connectivity to be friendly to runtime filter.
if (physicalHashJoin.getGroupExpression().isPresent()
&& physicalHashJoin.getGroupExpression().get().getOwnerGroup() != null
&& !physicalHashJoin.getGroupExpression().get().getOwnerGroup().isStatsReliable()) {
int leftConnectivity = computeConnectivity(physicalHashJoin.left(), context);
int rightConnectivity = computeConnectivity(physicalHashJoin.right(), context);
if (rightConnectivity < leftConnectivity) {
leftRowCount += 1;
}
Expand All @@ -371,6 +372,10 @@ public Cost visitPhysicalHashJoin(
leftRowCount += 1e-3;
}
}
if (!physicalHashJoin.getGroupExpression().get().getOwnerGroup().isStatsReliable()) {
// if a table with higher connectivity, move it to top-join. it is good for runtime filter.
leftRowCount -= rightConnectivity * probeStats.getWidthInJoinCluster();
}

/*
pattern1: L join1 (Agg1() join2 Agg2())
Expand Down

0 comments on commit 766e5fa

Please sign in to comment.