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);
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;
还想SQL写的简单还想执行快?反正能接受的速度就行呗
不知道你表的数据量级,不同量级, Oracle 的执行计划是不同的. 你的问题最好上个查询行计划截图,比较清楚, INSERT INTO 可以考虑下 merge
通常来说,这种not in/not exists的SQL快不了,有这种需求的数据本身已经决定了不可能秒出,更何况这个SQL没有任何过滤条件
(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;
你的问题最好上个查询行计划截图,比较清楚, INSERT INTO 可以考虑下 merge