简体   繁体   English

删除查询-提高性能

[英]Delete Query -To Improve Performance

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. 这可能会更有效率... in子句可能比连接或存在慢。.也返回1(因为我们只是检查是否存在而不是值)而不是查找每个值快一点。

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. 但是,在不知道特定索引,全表关系和数据量以及执行计划的情况下,这是基于“缓慢”的“最佳猜测”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM