--删除的数据量为2万条
--table1 数据量为百万级,table2为时间窗 仅一条记录
DELETE /*+ BYPASS_UJVC*/
FROM (SELECT
A.*
FROM table1 A, table2 B
WHERE A.INSERTDATE >= B.ETLNOWSTATDATE
AND A.INSERTDATE <= B.ETLLASTENDDATE) ;
--执行0.01s
delete from table1 a
where a.INSERTDATE >= (select b.statdate from table2 b)
and a.INSERTDATE <= (select b.enddate from table2 b)
--执行90s
------其他解决方案-------------------- 路过关注下,共求结果。顶下! ------其他解决方案-------------------- 这样不行么:
delete from table1 a where exists(select 1 from table2 B where A.INSERTDATE >= B.ETLNOWSTATDATE AND A.INSERTDATE <= B.ETLLASTENDDATE) ------其他解决方案--------------------
--对于你第一种方法,我测试了一下
--删除起作用的是右面的表,这种写法删除的是 B表
DELETE /*+ BYPASS_UJVC*/
FROM (SELECT
A.*
FROM table1 A, table2 B
WHERE A.INSERTDATE >= B.ETLNOWSTATDATE
AND A.INSERTDATE <= B.ETLLASTENDDATE) ;