Below is the query I wrote, wanted to know if i can improve the performance further.Can any one please help me?
DELETE FROM GLOBAL_TEMP
WHERE EXISTS (
SELECT GLOBAL_TEMP.ASSET_ID
FROM TEMP AEE
WHERE GLOBAL_TEMP.ASSET_ID = AEE.ID_ASSET
AND GLOBAL_TEMP.TYPE = 'abcdef'
AND AEE.id_temp_notation
IN (SELECT ID FROM TEMP2 WHERE IS_DISPLAYABLE = 'N')
);
This would likely be a bit more efficient... the in clause could be slow compared to a join or an exists.. also returning 1 (since we're just checking for existence and not values) instead of looking up each value would likely be slightly faster.
DELETE FROM GLOBAL_TEMP
WHERE EXISTS (
SELECT 1
FROM TEMP AEE
INNER JOIN temp2 t2
on AEE.ID_temp_notation = t2.id
WHERE GLOBAL_TEMP.ASSET_ID = AEE.ID_ASSET
AND GLOBAL_TEMP.TYPE = 'abcdef'
and t2.is_Displayable='N');
However, without knowing specific indexes, full table relationships and volume of data along with execution plans, this is a "best guess" based on "IN" typically being slow.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.