Skip to content

[Fusion] Avoid a duplicate selection row read when initializing composite objects - #10078

Merged
michaelstaib merged 2 commits into
mainfrom
mst/value-fast
Jul 10, 2026
Merged

michaelstaib merged 2 commits into
mainfrom
mst/value-fast

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 9, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes Fusion result-object initialization by avoiding an extra meta-db lookup when a CompositeResultElement already has direct selection metadata available, reducing redundant reads on a hot path in result completion.

Changes:

  • Added a fast-path in TryGetSelectionContext to derive type directly from target.Selection when present, bypassing target.Type.
Comments suppressed due to low confidence (1)

src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs:409

  • This adds an extra metadb selection-row read when target.Selection is null: the code reads target.Selection (null), then calls target.Type (which reads Selection again), and then the loop reads current.Selection again. Since TryGetSelectionContext already knows target.Selection is null in this branch, you can avoid the redundant reads by deriving the type from the parent and starting the selection walk from target.Parent.
        type = target.Type;

        if (type is null)
        {
            selection = null;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelstaib
michaelstaib merged commit 1d3055a into main Jul 10, 2026
7 of 8 checks passed
@michaelstaib
michaelstaib deleted the mst/value-fast branch July 10, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants