-
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
Query: Revisit Enumerable.Contains command caching #4605
Comments
@mikary we should go with the "Do not enter Enumerable.Contains commands into the cache" option |
@rowanmiller please no, I haven't compared performance between EF6 and EF7 yet but using EF6 for a moderately bulky query that includes a contains expression that is never more than ten items, about ~80-90ms is spent in code-land before the query is made. When I drop down to Dapper, maybe 10ms is spent. I believe this is more due to the 'bulk' of the query (aggregation- and join-heavy) needing to be recompiled each time merely because the Contains disqualifies it from being cached. Some thoughts:
I'm not sure what discussions have been had around this before, at least here on GitHub. |
@tuespetre Keep in mind that we have two stages at which we cache the outcome of EF Core's query compilation. At a very high level:
The proposal described above is to force query plans for queries that use Note that although in principle performance wise this approach might not be as good as generating SQL with a placeholder, we expect it to be comparable because a lot of the heavy lifting in query compilation actually happens in the generation of the query plan (which is still going to be cached) as opposed to during the SQL generation. |
@divega thanks for the explanation! Is that different than what EF6 had done then? |
Yes, it is different in that EF6 only had one level of query caching and so queries that used |
Ok, well that is awesome and I have nothing else to says besides "good job team"! 🎉 |
Different SQL is generated for Enumerable.Contains depending on the contents of the enumerable. The second level (command) caching of these commands does not currently have any kind of eviction policy and may grow out of control.
Possible solutions to the issue include:
The text was updated successfully, but these errors were encountered: