I am experiencing a really poor performance from Entity Framework.
I am binding it to views, and querying them takes 3-6x longer using EF.
Here is my test case (pseudo), Regular select of the same data:
Select * FROM myView
WHERE DateField > X
AND DateField < Y AND ID in ('a','b')
AND [expirationDateTime] = '9999-12-31'
Execution Time: 0:30
EF generated SQL
exec sp_executesql N'SELECT
[Extent1].[Field1] AS [Field1],
...
FROM (SELECT
[myView].Field1 AS [Field1]
...
FROM [dbo].[myView] AS [myView]) AS [Extent1]
WHERE ([Extent1].[DateField] > @p_linq__0)
AND ([Extent1].DateField] < @p_linq__1)
AND ([Extent1].[expirationDateTime] = @p__linq__2)',
N'@p__linq__0 datetime,@p__linq__1 datetime,@p__linq__2 datetime',
@p__linq__0='2010-12-01 00:00:00',
@p__linq__1='2011-01-06 00:00:00',
@p__linq__2='9999开发者_Python百科-12-31',
Execution Time: 2:54
How can EF query be optimized considering that there is limited control over how the SQL is rendered?
AND ID in ('a','b')
seams to be missing from the EF version. That might do a big difference.
did you put WITH (NOLOCK) in all of your views? lol
精彩评论