-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
EF7 fires several queries instead of 1 query with smart join -- and worse #4520
Comments
This happens because of
part in the projection. EF currently can't handle collection projections well. Queries you see are not correlated with the main query because that correlation is happening on the client currently. You can try using Include on that navigation, projecting the entire collection and then performing the rest of the query on the client. It will still fetch all the rows from ProductMultimedias but should do so only once, and not 8 times. |
Something like this:
|
Improving this translation is already tracked by #4007, so I'll close this one out. |
'not planned'? Why? We always intent to fix bugs in our code. I guess I should stick to EF6 forever? EF Core is still not up to par compared to EF6 when it comes down to query generation. |
@jancg This is a really old issue that was closed 6 years ago. All that is happening here is that the GitHub closed-reason is changing. If you think there is still a bug here, then please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
HAS BEEN SOLVED IN 1.0.0
productNumbers is a List and contains 8 product numbers.
EF7 fires 9 queries to SQL Server. The first query actually translates neatly to IN (...8 numbers...). Next EF7 fires 8 identical queries to SQL Server that aren't even correlated to the 8 numbers. 8 times tens of thousands of records from the ProductMultimedias table are fetched!
The text was updated successfully, but these errors were encountered: