-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Milestone
Description
What problem are you trying to solve?
"Query is fast in SSMS but slow in production" kind of performance issues, where query is parametrized by EF and SQL Server chooses query execution plan suboptimal for concrete parameter value.
For example:
SELECT TOP(1000) * FROM dbo.MyView -- fastint pageSize = 60
if (loadMore) pageSize = 1000;
ctx.MyView.Take(pageSize).ToArray(); //slow when pageSize is 1000Describe the solution you'd like
Introduce an EF.Constant() mechanism, which is identified by EF Core and prevents parameterization.
This goes hand in hand with #28151
ctx.MyView.Take(() => EF.Contant(pageSize)).ToArray();
ctx.MyView.Where(b => b.Name == EF.Constant("bar"))Alternatively, add support for query hints like RECOMPILE or OPTIMIZE FOR
/cc @dsyme @NinoFloris @roji
bachratyg, jernejk and lampersky