我创建了以下索引来覆盖选择顶部语句。
然而,它仍需要一段时间(我的表有5000万行,需要19秒),执行计划显示仍然有一个“排序”操作?
执行计划如下:
-- Column A, B have type of int
create unique index ix_ on T (A, B) with (data_compression = page)
-- tried to create non-unique index too and the execution plan is the same
select top 20 A, B from T order by A, B -- 19 seconds
select top 20 A, B from T -- return result instantly
然而,它仍需要一段时间(我的表有5000万行,需要19秒),执行计划显示仍然有一个“排序”操作?
执行计划如下: