一尘不染

为什么要对我的聚集索引进行扫描?

sql

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?什么会导致对聚集索引进行索引扫描?谢谢


阅读 166

收藏
2021-03-17

共1个答案

一尘不染

这是一篇有关SQL Server何时到达“临界点”并从索引查找切换到索引/表扫描的不错的博客文章:

http://www.sqlskills.com/BLOGS/KIMBERLY/post/The-Tipping-Point-Query-
Answers.aspx

您可能希望查看查询的过滤方式,因为临界点通常比人们期望的要少得多。

2021-03-17