23 lines
1.1 KiB
Diff
23 lines
1.1 KiB
Diff
# UNDF: UNDF-2026-000000683
|
||
# UNDF:
|
||
--- a/src/planner/subquery/has_correlated_expressions.cpp
|
||
+++ b/src/planner/subquery/has_correlated_expressions.cpp
|
||
@@ -50,12 +50,16 @@ unique_ptr<Expression> HasCorrelatedExpressions::VisitReplace(BoundSubqueryExpression &expr,
|
||
if (!expr.IsCorrelated()) {
|
||
return nullptr;
|
||
}
|
||
+ // Build O(1) lookup set from the subquery binder's correlated columns once per call.
|
||
+ // Previously the inner std::find was O(M) for each of the N outer correlated_columns,
|
||
+ // giving O(N×M) total. With the CorrelatedColumns::Contains() O(1) helper (backed by
|
||
+ // binding_set) this becomes O(N).
|
||
// check if the subquery contains any of the correlated expressions that we are concerned about in this node
|
||
for (idx_t i = 0; i < correlated_columns.size(); i++) {
|
||
- if (std::find(expr.binder->correlated_columns.begin(), expr.binder->correlated_columns.end(),
|
||
- correlated_columns[i]) != expr.binder->correlated_columns.end()) {
|
||
+ if (expr.binder->correlated_columns.Contains(correlated_columns[i])) { // O(1) via binding_set; was O(M) std::find
|
||
has_correlated_expressions = true;
|
||
break;
|
||
}
|
||
}
|
||
return nullptr;
|
||
}
|