--删除的数据量为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) ;
--删除的数据量为2万条 --table1 数据量为百万级,table2为时间窗 仅一条记录 今儿又找了一个环境,在plsql中进行了测试。 测试结果如下: DELETE /*+ BYPASS_UJVC*/ FROM (SELECT A.* FROM table1 A, table2 B WHERE A.INSERTDATE >= B.ETLNOWSTATDATE AND A.INSERTDATE <= B.ETLLASTENDDATE) ; --第一种删除方式,删除AB俩张表的记录; --~~~~~~~~~~~~~~~~~~~~~~~ DELETE /*+ BYPASS_UJVC*/ FROM (SELECT A.* FROM table2 B, table1 A WHERE A.INSERTDATE >= B.ETLNOWSTATDATE AND A.INSERTDATE <= B.ETLLASTENDDATE) ; --调换AB的顺序,只删除了达标A表的记录。