这是查询:
SELECT top 100 a.LocationId, b.SearchQuery, b.SearchRank
FROM dbo.Locations a
INNER JOIN dbo.LocationCache b ON a.LocationId = b.LocationId
WHERE a.CountryId = 2
AND a.Type = 7
Run Code Online (Sandbox Code Playgroud)
位置索引:
PK_Locations:
LocationId
IX_Locations_CountryId_Type:
CountryId,Type
LocationCache索引:
PK_LocationCache:
LocationId
IX_LocationCache_LocationId_SearchQuery_SearchRank:
LocationId,SearchQuery,SearchRank
执行计划:

所以它正在使用覆盖索引做一个关于位置的索引搜索,很酷.
但是为什么它在LocationCache覆盖索引上进行索引扫描?
覆盖索引在索引中具有LocationId,SearchQuery,SearchRank(而不是"包含的列").
将鼠标悬停在索引扫描上:

此查询需要进入由自动完成插件使用的SQL Server FTS目录提供的索引视图,因此需要100%优化.
目前,上述查询需要3秒钟.它应该<0.
有任何想法吗?
t-sql indexing performance sql-server-2008 sql-execution-plan