Repository navigation
Unified: Fix bad join - #22971
Merged
Merged
Unified: Fix bad join#22971
Conversation
Before
```
Evaluated relational algebra for predicate StaticNameBinding::unqualifiedMemberAccess/4#0730f1f3@db9ae7oh with tuple counts:
275976 ~4% {2} r1 = SCAN `StaticNameBinding::unqualifiedMemberAccessDepth/1#8b18133c` OUTPUT In.1, In.0
583240193 ~1% {2} | JOIN WITH `FacadeAst::Unified::AstNode.getDepth/0#e89ff1d9#bf_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1
276222 ~10% {4} | JOIN WITH `StaticNameBinding::unqualifiedMemberAccessCand/4#dd3e0587_0312#join_rhs` ON FIRST 2 OUTPUT Lhs.0, Rhs.2, Rhs.3, Lhs.1
return r1
```
After
```
Evaluated relational algebra for predicate StaticNameBinding::unqualifiedMemberAccess/4#0730f1f3@6b447707 with tuple counts:
276222 ~0% {5} r1 = JOIN `StaticNameBinding::unqualifiedMemberAccessCand/4#dd3e0587` WITH `StaticNameBinding::unqualifiedMemberAccessDepth/1#8b18133c` ON FIRST 1 OUTPUT Lhs.3, Rhs.1, Lhs.1, Lhs.2, Lhs.0
276222 ~10% {4} | JOIN WITH `FacadeAst::Unified::AstNode.getDepth/0#e89ff1d9` ON FIRST 2 OUTPUT Lhs.4, Lhs.2, Lhs.3, Lhs.0
return r1
```
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the join-ordering annotations in static name binding.
No open issues 🎉
What changed in this PR
This PR improves join ordering in Unified’s static name binding, reducing intermediate results when resolving unqualified member accesses.
Changes:
- Adds
pragma[only_bind_into]to theaccessandaccessingClasscandidate arguments. - Guides evaluation toward the smaller candidate join before checking class depth, without changing the predicate’s logical conditions.
| File | Description |
|---|---|
unified/ql/lib/codeql/unified/internal/StaticNameBinding.qll |
Adds binding annotations to improve join ordering in unqualifiedMemberAccess. |
Review effort: Balanced (auto)
aschackmull
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before
After
DCA show a small speedup.