Consider removing identifier orderings when doing identity resolution
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Stale
- Domain
- databases, performance
Research direction
Start by tracing related-entity loading, identity resolution, and the shaper described in the issue, then compare generated SQL with and without identifier orderings. Measure server-side ordering costs against the shaper's local dictionary lookups, and consider the work done only when the performance trade-off and affected query behavior are demonstrated.
Written by the indexing model from the issue text.
Description
When loading related entities, we currently generate orderings to group together rows for the same entity. This is necessary for queries without identity resolution, since the shaper detects that new entities by the change in identifier. However, queries with identity resolution perform local lookup anyway, so these orderings aren't needed.
For example, consider a Blog with two collection navigations, Posts and Authors. When loading this entire graph, we currently generate:
SELECT [b].[Id], [b].[Name], [p].[Id], [p].[BlogId], [a].[Id], [a].[BlogId]
FROM [Blogs] AS [b]
LEFT JOIN [Post] AS [p] ON [b].[Id] = [p].[BlogId]
LEFT JOIN [Author] AS [a] ON [b].[Id] = [a].[BlogId]
ORDER BY [b].[Id], [p].[Id], [a].[Id]
Queries using identity resolution could omit the last two orderings.
This would potentially imply more local dictionary lookups, as rows are returned unordered and the shaper needs to jump back and forth between instances. My gut feeling is that the server-side ordering is much more expensive, but we'd have to confirm this first.
/cc @smitpatel
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100