303696 {
303697 auto &left_child = *op.children[0];
303698 auto &right_child = *op.children[1];
303699 const auto lhs_cardinality = left_child.has_estimated_cardinality ? left_child.estimated_cardinality
303700 : left_child.EstimateCardinality(context);
303701 const auto rhs_cardinality = right_child.has_estimated_cardinality ? right_child.estimated_cardinality
303702 : right_child.EstimateCardinality(context);
303703
303704 auto build_sizes = GetBuildSizes(op, lhs_cardinality, rhs_cardinality);
303705 auto &left_side_build_cost = build_sizes.left_side;
303706 auto &right_side_build_cost = build_sizes.right_side;
303707
303708 bool swap =
false;
303709
303710 idx_t left_child_joins = ChildHasJoins(*op.children[0]);
303711 idx_t right_child_joins = ChildHasJoins(*op.children[1]);
303712
303713
303714
303715 if (right_child_joins == 0 && left_child_joins > 0) {
303716 right_side_build_cost *= (1 + PREFER_RIGHT_DEEP_PENALTY);
303717 }
303718
303719
303720
303721
303722 if (right_side_build_cost > left_side_build_cost) {
303724 }
303725
303726
303727 if (rhs_cardinality == lhs_cardinality && !preferred_on_probe_side.empty()) {
303728
303729 auto bindings_left = left_child.GetColumnBindings();
303730 auto bindings_right = right_child.GetColumnBindings();
303731 auto bindings_in_left = ComputeOverlappingBindings(bindings_left, preferred_on_probe_side);
303732 auto bindings_in_right = ComputeOverlappingBindings(bindings_right, preferred_on_probe_side);
303733
303734
303735
303736
303737
303738
303739
303740 if ((swap && bindings_in_left > bindings_in_right) || (!swap && bindings_in_right > bindings_in_left)) {
303742 }
303743 }
303744
303745 if (swap) {
303746 FlipChildren(op);
303747 }
303749}
void swap(Mat &a, Mat &b)