我正在尝试查看一个简单的 select Top (n) 的查询计划。每次我更改 n(我获取的记录数)时,查询计划都会更改,其中 Select Top 10 会特别导致性能问题,小于 10 或大于 10 时查询运行顺利。
查询由实体框架 (4.2) 生成,如果它有所作为。
查询是:
exec sp_executesql N'SELECT TOP (10)
[Project1].[Id] AS [Id],
[Project1].[DateReceived] AS [DateReceived],
[Project1].[Status] AS [Status],
[Project1].[Subject] AS [Subject],
[Project1].[Description] AS [Description],
[Project1].[Path] AS [Path],
[Project1].[C1] AS [C1],
[Project1].[C2] AS [C2],
[Project1].[C3] AS [C3],
.
.
.
.
.
.
.
WHERE [Project1].[row_number] > 0
ORDER BY [Project1].[DateReceived] DESC',N'@p__linq__0 int,@p__linq__1 int,@p__linq__2 datetime2(7),@p__linq__3 datetime2(7),@p__linq__4 nvarchar(4000),@p__linq__5 nvarchar(4000),@p__linq__6 nvarchar(4000),@p__linq__7 nvarchar(4000)',@p__linq__0=-1,@p__linq__1=-1,@p__linq__2='2013-03-15 00:00:00',@p__linq__3='2013-04-15 23:59:55',@p__linq__4=N'ALL',@p__linq__5=N'ALL',@p__linq__6=N'',@p__linq__7=N'%%'
为什么 TOP 10 会导致性能问题?
我还不能分享图片,这里是链接: