SQL 2000
NED表具有指向SIGN表NED.RowID到SIGN.RowID的外键
SIGN表具有NED表SIGN.SignID到NED.SignID的外键
RowID和SignID是作为GUID的群集主键(不是我的选择)
WHERE子句是:
FROM
[SIGN] A
INNER JOIN NED N ON A.SIGNID = N.SIGNID
INNER JOIN Wizard S ON A.WizardID = S.WizardID
INNER JOIN [Level] SL ON N.LevelID = SL.LevelID
LEFT JOIN Driver DSL ON SL.LevelID = DSL.LevelID
AND DSL.fsDeptID = @fsDeptID
INNER JOIN [Character] ET ON S.CharacterID = ET.CharacterID
INNER JOIN Town DS ON A.TownID = DS.TownID
WHERE
(A.DeptID = @DeptID OR
S.DeptID = @DeptID
AND
A.[EndTime] > @StartDateTime AND A.[StartTime] < @EndDateTime
AND
A.NEDStatusID = 2
为什么在SIGN表上对此查询有INDEX SCAN?什么会导致对聚集索引进行索引扫描?谢谢
最佳答案
这是一篇有关SQL Server何时到达“临界点”并从索引查找切换到索引/表扫描的不错的博客文章:
http://www.sqlskills.com/BLOGS/KIMBERLY/post/The-Tipping-Point-Query-Answers.aspx
您可能希望查看查询的过滤方式,因为临界点通常比人们期望的要少得多。