Sqlserver 2005 删除查询与连接
我有以下查询删除记录,这个查询中有什么可以优化的吗?使用连接删除记录的方式是完美的吗?使用连接记录删除任何开销?
DELETE BATCH_SCORE
FROM BATCH_SCORE BS JOIN INQUIRY_MATCH IM ON BS.BATCH_ID = IM.BATCH_ID AND IM.INQUIRY_MATCH_ID = #inquiryMatchId#
WHERE NOT EXISTS (SELECT TOP 1 1 FROM INQUIRY_MATCH WHERE BATCH_ID = BS.BATCH_ID AND CURRENT_STATE IN ('OPN','RVW',
'ASN', 'ESC', 'PND')) AND BS.PERMANENT_BATCH = 'N'
我写了如下的新查询,新查询比上面的更好吗
DELETE
BATCH_SCORE
FROM
BATCH_SCORE BS
WHERE
NOT EXISTS (
SELECT
TOP 1 1
FROM
INQUIRY_MATCH
WHERE
INQUIRY_MATCH_ID = 1011 AND
BATCH_ID = BS.BATCH_ID AND
CURRENT_STATE IN ('OPN',
'RVW',
'ASN',
'ESC',
'PND')) AND
BS.PERMANENT_BATCH = 'N'