Why is this an Index Scan and not a Index Seek?

后端 未结 5 995
南方客
南方客 2020-12-24 14:59

Here\'s the query:

SELECT      top 100 a.LocationId, b.SearchQuery, b.SearchRank
FROM        dbo.Locations a
INNER JOIN  dbo.LocationCache b ON a.LocationId          


        
5条回答
  •  一生所求
    2020-12-24 15:30

    Whilst bearing in mind that it will result in a query that may perform badly as and when additional changes are made to it, using an INNER LOOP JOIN should force the covering index to be used on dbo.LocationCache.

    SELECT      top 100 a.LocationId, b.SearchQuery, b.SearchRank
    FROM        dbo.Locations a
    INNER LOOP JOIN dbo.LocationCache b ON a.LocationId = b.LocationId
    WHERE       a.CountryId = 2
    AND         a.Type = 7
    

提交回复
热议问题