【发布时间】:2015-10-12 20:11:09
【问题描述】:
以下查询的执行计划(由 nhibernate 生成)显示排序运算符正在减少排序操作后的行数。什么可能导致这种情况?通过对左外连接使用哈希连接提示可以提高查询性能,但是由于估计错误,SQL 改为使用嵌套循环。我想知道排序运算符是否会导致这种情况。
SELECT TOP (26)
col_0_0_,
col_1_0_,
col_2_0_,
col_3_0_
FROM (
select
table0.table_id as col_0_0_,
propertyst2_.dataTypeString as col_1_0_,
propertyst3_.dataTypeString as col_2_0_,
propertyst4_.dataTypeString as col_3_0_ ,
ROW_NUMBER() OVER(ORDER BY propertyst2_.dataTypeString) as __hibernate_sort_row
from dbo.Tables table0
left outer join dbo.PropertyDataString propertyst2_ on table0.table_id=propertyst2_.parent_id and (propertyst2_.propertyType_id='p0')
left outer join dbo.PropertyDataString propertyst3_ on table0.table_id=propertyst3_.parent_id and (propertyst3_.propertyType_id='p1')
left outer join dbo.PropertyDataString propertyst4_ on table0.table_id=propertyst4_.parent_id and (propertyst4_.propertyType_id='p2')
where table0.tableType_id='p3'
) as query
WHERE query.__hibernate_sort_row > 221052 ORDER BY query.__hibernate_sort_row
【问题讨论】:
-
这个表的统计日期怎么样?
-
我已经多次更新统计数据,还添加了覆盖索引(这是在开发服务器上)
-
可能是
top 26Row 目标的效果。