Skip to content

Consider removing identifier orderings when doing identity resolution #24377

Description

@roji

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions