GroupJoin is doing aggregate in memory instead of on DB #13887
Labels
area-query
closed-out-of-scope
This is not something that will be fixed/implemented and the issue is closed.
customer-reported
type-enhancement
GroupJoin()
is emitting incorrect Sql, resulting in inefficient queries.Steps to reproduce
The basic building blocks:
Blog (BlogId, BlogName)
Post (PostId, BlogId, Title, Body)
with the obvious FKs.
I want to count how many posts in each blog have a title starting with the letter "B", ordered by that count descending:
This emits the following Sql (using the Sql Server):
Similarly when using Npgsql:
As you can see, this is loading all posts into memory, in their entirety, which is going to be hugely expensive if I've got tens of thousands of posts in each blog. All I want is a count.
The Sql I would want to see would be something more like:
Further technical details
EF Core version: 2.1.4
Database Provider: Microsoft.EntityFrameworkCore.SqlServer and Npgsql
Operating system: Windows 10
IDE: (e.g. Visual Studio 2017 15.8.2)
The text was updated successfully, but these errors were encountered: