github-actions[bot] commented on code in PR #67438:
URL: https://github.com/apache/doris/pull/67438#discussion_r3931563266
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -1192,12 +1235,110 @@ public List<Expression> bindSlotByScope(UnboundSlot
unboundSlot, Scope scope) {
}
}
+ protected SlotBinding bindSlotByScope(
+ UnboundSlot unboundSlot, Scope scope, boolean
bindRelationQualifierOnly) {
+ return bindRelationQualifierOnly
+ ? bindSlotByRelationQualifier(unboundSlot, scope)
+ : new SlotBinding(bindSlotByScope(unboundSlot, scope), false);
+ }
+
+ /** Bind a multipart slot as a relation-qualified column, without treating
its first part as a column. */
+ protected SlotBinding bindSlotByRelationQualifier(UnboundSlot unboundSlot,
Scope scope) {
+ List<String> nameParts = unboundSlot.getNameParts();
+ Optional<Pair<Integer, Integer>> idxInSql =
unboundSlot.getIndexInSqlString();
+ List<? extends Expression> bounded;
+ switch (nameParts.size()) {
+ case 1:
+ bounded = ImmutableList.of();
+ break;
+ case 2:
+ bounded = bindExpressionByTableColumn(
+ unboundSlot, nameParts, idxInSql, scope, false);
+ break;
+ case 3:
+ bounded = bindExpressionByDbTableColumn(
+ unboundSlot, nameParts, idxInSql, scope, false);
+ break;
+ default:
+ bounded = bindExpressionByCatalogDbTableColumn(
+ unboundSlot, nameParts, idxInSql, scope, false);
+ break;
+ }
+ return new SlotBinding(bounded, containsRelationQualifier(nameParts,
scope));
+ }
Review Comment:
**[P2] Avoid scanning the whole scope for every qualified reference**
`bindSlotByRelationQualifier` computes `containsRelationQualifier(...)`
unconditionally, even when `bounded` already contains a local match and for the
outer-scope probe at line 328 where the returned occupancy flag is discarded.
That helper linearly walks `scope.getSlots()` and performs case-mode lookups
per visited entry, bypassing `Scope.findSlotIgnoreCase`'s index for schemas
above 500 columns. In a correlated filter with N references to an outer alias
over a W-column inner scope, each local miss scans all W slots before the
indexed outer hit, adding O(N * W) analysis work. Please compute occupancy only
after the complete local relation chain has no bound candidate, use a
bound-only outer probe, and cache/index qualifier presence if the necessary
miss check must stay fast on wide scopes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]