SQL - improve NOT EXISTS query performance

前端 未结 7 1827
名媛妹妹
名媛妹妹 2021-02-07 09:08

Is there a way I can improve this kind of SQL query performance:

INSERT
INTO ...
WHERE NOT EXISTS(Validation...)

The problem is when I have ma

7条回答
  •  情歌与酒
    2021-02-07 09:57

    Off the top of my head, you could try something like:

     TRUNCATE temptable
     INSERT INTO temptable ...
     INSERT INTO temptable ... 
     ...
     INSERT INTO realtable
     SELECT temptable.* FROM temptable
     LEFT JOIN realtable on realtable.key = temptable.key
     WHERE realtable.key is null
    

提交回复
热议问题