SQL Server索引不考虑执行计划

时间:2016-08-19 12:28:00

标签: sql sql-server

我在表格中有以下索引。但在查看查询计划时,看起来索引不被考虑用于索引扫描。有人可以告诉我这里有什么不见了吗?

索引:

CREATE NONCLUSTERED INDEX [IX_Profile_ProfileStatusId_IsVoiceMailDeposit_IsVoiceMailRetrieve] 
   ON [dbo].[Profile] ([ProfileStatusId], [IsVoiceMailDeposit],[IsVoiceMailRetrieve])
      INCLUDE ([Id], [LocationId], [SubscriberId], [PersonId], [PartitionId],[ProfileTypeId], [InternalCallerId], [Extension], [IsPrimary], [IsInDirectory],[IsSuspended], [TnId], [BoblFirstName], [BoblLastName], [BoblEmail],[TnCountryId])
    GO

执行计划:

enter image description here

这个计划是一个更大的SP的一部分,其他很多表。但是,如果我运行以下提取的测试查询,则会考虑索引。它只是当它与存储过程结合时,它无法使用索引。

测试查询:

select 
    pr.PartitionId, pr.PersonId, pr.InternalCallerId, pr.Extension, pr.TnId, pr.TnCountryId
from 
    [Profile] pr 
left join 
    [Person] pe with (nolock) on pr.PersonId = pe.Id
inner join 
    Partition pt with (nolock) on pr.PartitionId = pt.Id
where 
    --a.IsDeleted = 0 and  
    --(svcA.ServiceClassId in (select ServiceClassId from [service_ServiceClassProfileTypeMapping]) or svcA.ServiceClassId is null)and
    pr.ProfileStatusId = 0 -- only Active
    and 0 = pr.IsVoiceMailDeposit and 0 = pr.IsVoiceMailRetrieve

测试查询的计划:(请注意,使用了相同的谓词列表)

enter image description here

查询:http://pastebin.com/YJbsN4dy

计划:http://pastebin.com/7zR5W8ie

查看:http://pastebin.com/cdxTSXcs

0 个答案:

没有答案