2013-05-20 173 views
0

我有以下SQL查询差强人意:提高性能

SELECT 
    Count(ExtCardID) as CardCount 
from 
    CardIDs CARDS with (NoLock) 
inner join 
    (select CustomerPK 
    from GroupMembership with (NoLock) 
    where CustomerGroupID = 14 and Deleted = 0) as GM on GM.CustomerPK = CARDS.CustomerPK 

以下Select部分从上述联接返回的800万个记录:

select 
    CustomerPK from GroupMembership with (NoLock) 
where 
    CustomerGroupID = 14 and Deleted = 0 

是否有更好的办法写上面的sql代码?请指教。

+1

你有什么指标?你能发布执行计划吗? –

回答