下面是我们在 2MM 记录表 (SQL Server 2005) 上的索引混乱的一部分。显然,有机会将它们击倒。该表总共有 16 个索引,包括一个聚集的 PK on [MemberID], [RegistryID],[end_date]
,但我只列出了似乎可以合并的那些。
[ix_IndexName7]
例如,我很想放弃,因为它是多余的。但根据sys.dm_db_index_usage_stats
它似乎在一些查询计划中。
这是我的问题。假设我放弃[ix_IndexName7]
或[ix_IndexName30]
(我认为它被 覆盖[idxMemberRegistry1]
)。当一个查询计划试图找到但找不到[ix_IndexName7]
时,优化器会神奇地合并第一列为 的其他索引之一[MemberID]
吗?或者我是否必须找到使用该表的任何 SP/视图/函数并重新编译它们(这会很糟糕,因为可能有垃圾负载)。或者是其他东西?
我希望这个问题很清楚。我会很感激任何意见!
CREATE NONCLUSTERED INDEX [idx_RegistryID] ON [dbo].[Member_Registry] ([RegistryId], [end_date], [MemberId])
CREATE UNIQUE NONCLUSTERED INDEX [idx_MemberID] ON [dbo].[Member_Registry] ([MemberId], [RegistryId], [end_date]) INCLUDE ([Due_Date])
CREATE NONCLUSTERED INDEX [ix_IndexName7] ON [dbo].[Member_Registry] ([end_date]) INCLUDE ([MemberId])
CREATE NONCLUSTERED INDEX [ix_IndexName11] ON [dbo].[Member_Registry] ([end_date]) INCLUDE ([MemberId], [RegistryId])
CREATE NONCLUSTERED INDEX [ix_IndexName16] ON [dbo].[Member_Registry] ([end_date]) INCLUDE ([ContinuousEnrol], [MemberId], [RegistryId])
CREATE NONCLUSTERED INDEX [ix_IndexName30] ON [dbo].[Member_Registry] ([end_date]) INCLUDE ([MemberId], [P4P_Patient], [RegistryId])
CREATE NONCLUSTERED INDEX [ix_IndexName29] ON [dbo].[Member_Registry] ([end_date], [ContinuousEnrol]) INCLUDE ([MemberId], [RegistryId])
CREATE NONCLUSTERED INDEX [idxMemberRegistry1] ON [dbo].[Member_Registry] ([end_date], [MemberId], [RegistryId]) INCLUDE ([COL_D2yr], [ContinuousEnrol], [P4P_AAB], [P4P_ACE], [P4P_CERVICAL], [P4P_Chlamydia], [P4P_COL], [P4P_DGX], [P4P_DIU], [P4P_MAMMO], [P4P_Patient], [start_date])
CREATE NONCLUSTERED INDEX [idx_AllPatients] ON [dbo].[Member_Registry] ([MemberId], [RegistryId], [end_date]) INCLUDE ([EXCLUSION_STATUS], [P4P_Patient])
CREATE NONCLUSTERED INDEX [idx_Exclusion_Status] ON [dbo].[Member_Registry] ([MemberId], [RegistryId], [EXCLUSION_STATUS])