0

我有archived_events以下索引的表。

    CREATE NONCLUSTERED INDEX [IX_archived_events_5] ON [dbo].[archived_events]
    (
        [account_id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
    GO

ALTER TABLE [dbo].[archived_events] ADD  CONSTRAINT [PK_archived_events] PRIMARY KEY CLUSTERED 
(
    [event_type] DESC,
    [id] DESC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
GO

问题是,当我执行以下查询时,我在执行计划中看到它对 [PK_archived_events] 进行聚集索引扫描

SELECT *                                  
FROM   archived_events ae WITH(nolock) 
WHERE     ( 30 = ae.[account_id] ) 

非聚集索引被忽略的原因是什么?

另请注意,这是 SQL Azure,不确定是否重要。

4

1 回答 1

0

该表具有干扰索引的 nvarchar(max) 列。我已将它们转换为 nvarchar(n) 并且索引现在可以使用。

于 2012-11-08T13:50:19.163 回答