insert into ultrax.pre_forum_post_tableid
(postid)
select data_post_id as postid
from kernels.csdn_discuz_topic_post
where data_post_id not in
(select postid from ultrax.pre_forum_post_tableid);
uj5u.com熱心網友回復:
上執行計劃吧。通常來說,這種not in/not exists的SQL快不了,有這種需求的資料本身已經決定了不可能秒出,更何況這個SQL沒有任何過濾條件
uj5u.com熱心網友回復:
用EXISTS 太慢的話 寫存盤程序回圈插入執行吧uj5u.com熱心網友回復:
insert into ultrax.pre_forum_post_tableid(postid)
select data_post_id as postid
from kernels.csdn_discuz_topic_post a,
ultrax.pre_forum_post_tableid b
where a.data_post_id =b.post_id(+)
and b.post_id is null;
uj5u.com熱心網友回復:
還想SQL寫的簡單還想執行快?反正能接受的速度就行唄uj5u.com熱心網友回復:
不知道你表的資料量級,不同量級, Oracle 的執行計劃是不同的.你的問題最好上個查詢行計劃截圖,比較清楚, INSERT INTO 可以考慮下 merge
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/31357.html
標籤:開發
