Unified: Fix bad join in derivedStoreReadStep - #22707
Merged
hvitved merged 1 commit intoSep 30, 2026
Merged
Conversation
Before
```
Pipeline standard for StaticNameBinding::derivedStoreReadStep/2#42234dff@fc4c9y3a was evaluated in 14 iterations totaling 10484ms (delta sizes total: 108052).
5330410 ~0% {3} r1 = JOIN `StaticNameBinding::TrackNamespace::track/1#cff0849d#reorder_1_0#prev_delta` WITH `StaticNameBinding::readStep/3#d06f28c6` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Rhs.2
2567 ~0% {2} | JOIN WITH `StaticNameBinding::NamespaceNode.getMember/1#62056d4e#prev` ON FIRST 2 OUTPUT Lhs.2, Rhs.2
{2} | REWRITE WITH TEST InOut.1 != InOut.0
2567 ~1% {2} | SCAN OUTPUT In.1, In.0
811176 ~0% {3} r2 = SCAN `StaticNameBinding::NamespaceNode.getMember/1#62056d4e#prev_delta` OUTPUT In.1, In.0, In.2
3703647034 ~1% {4} | JOIN WITH `StaticNameBinding::readStep/3#d06f28c6_102#join_rhs` ON FIRST 1 OUTPUT Rhs.1, Rhs.2, Lhs.1, Lhs.2
{4} | REWRITE WITH TEST InOut.3 != InOut.1
3703647034 ~0% {4} | SCAN OUTPUT In.0, In.2, In.1, In.3
105485 ~0% {2} | JOIN WITH `StaticNameBinding::TrackNamespace::track/1#cff0849d#reorder_1_0#prev` ON FIRST 2 OUTPUT Lhs.3, Lhs.2
108052 ~1% {2} r3 = r1 UNION r2
108052 ~1% {2} | AND NOT `StaticNameBinding::derivedStoreReadStep/2#42234dff#prev`(FIRST 2)
return r3
```
After
```
Pipeline standard for StaticNameBinding::derivedStoreReadStep/2#42234dff@7738dy18 was evaluated in 14 iterations totaling 42ms (delta sizes total: 108052).
5330410 ~0% {3} r1 = JOIN `StaticNameBinding::TrackNamespace::track/1#cff0849d#reorder_1_0#prev_delta` WITH `StaticNameBinding::readStep/3#d06f28c6` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Rhs.2
2567 ~0% {2} | JOIN WITH `StaticNameBinding::NamespaceNode.getMember/1#62056d4e#prev` ON FIRST 2 OUTPUT Lhs.2, Rhs.2
{2} | REWRITE WITH TEST InOut.1 != InOut.0
2567 ~1% {2} | SCAN OUTPUT In.1, In.0
811176 ~4% {3} r2 = SCAN `StaticNameBinding::NamespaceNode.getMember/1#62056d4e#prev_delta` OUTPUT In.0, In.2, In.1
5362528 ~0% {3} | JOIN WITH `StaticNameBinding::TrackNamespace::track/1#cff0849d#prev` ON FIRST 1 OUTPUT Rhs.1, Lhs.2, Lhs.1
105485 ~0% {2} | JOIN WITH `StaticNameBinding::readStep/3#d06f28c6` ON FIRST 2 OUTPUT Lhs.2, Rhs.2
105485 ~0% {2} | REWRITE WITH TEST InOut.0 != InOut.1
108052 ~1% {2} r3 = r1 UNION r2
108052 ~1% {2} | AND NOT `StaticNameBinding::derivedStoreReadStep/2#42234dff#prev`(FIRST 2)
return r3
```
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The annotations are semantically equivalent and the supplied evaluation confirms the intended performance improvement.
Review effort: Balanced
Findings: None
What changed in this PR
Optimizes derivedStoreReadStep by guiding the QL compiler toward a substantially cheaper join order.
Changes:
- Adds
only_bind_intohints for the shared member name. - Preserves query semantics while reducing evaluation time.
| File | Description |
|---|---|
unified/ql/lib/codeql/unified/internal/StaticNameBinding.qll |
Adds binding-direction hints to optimize name-binding joins. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
asgerf
approved these changes
Sep 30, 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 confirms.