Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop subquery pushdown for OrderBy over Distinct #34121

Open
roji opened this issue Jun 29, 2024 · 0 comments
Open

Stop subquery pushdown for OrderBy over Distinct #34121

roji opened this issue Jun 29, 2024 · 0 comments

Comments

@roji
Copy link
Member

roji commented Jun 29, 2024

For the following query:

_ = await context.Blogs.Distinct().OrderBy(b => b.Id).ToListAsync()

We currently produce:

SELECT [t].[Id], [t].[Name]
FROM (
    SELECT DISTINCT [b].[Id], [b].[Name]
    FROM [Blogs] AS [b]
) AS [t]
ORDER BY [t].[Id]

But the pushdown isn't needed, we can generate this instead (note that ORDER BY is processed after DISTINCT in SQL):

SELECT DISTINCT [b].[Id], [b].[Name]
FROM [Blogs] AS [b]
ORDER BY [t].[Id]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant