2013-05-20 206 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

你有什麼指標?你能發佈執行計劃嗎? –

回答