code1:
with tmp_1 as
(
select .....
)
select * from a where
not
exists (select * from tmp_1 t where t.code=b.code);
code2:
create table tmp_1 nologging as
select .....
;
select * from a where
not
exists (select * from tmp_1 t where t.code=b.code);上面两段代码中一个是内嵌视图tmp_1,另一个是表tmp_1(且无索引),
形成这两个tmp_1的select 语句是一样的,也就是说
这两个tmp_1中的记录是相同的,
表a和tmp_1都是100万条以上的记录。
问题:
这两段代码执行起来在速度上有什么区别?为什么?
with tmp_1 as
(
select .....
)
select * from a where
not
exists (select * from tmp_1 t where t.code=b.code);
code2:
create table tmp_1 nologging as
select .....
;
select * from a where
not
exists (select * from tmp_1 t where t.code=b.code);上面两段代码中一个是内嵌视图tmp_1,另一个是表tmp_1(且无索引),
形成这两个tmp_1的select 语句是一样的,也就是说
这两个tmp_1中的记录是相同的,
表a和tmp_1都是100万条以上的记录。
问题:
这两段代码执行起来在速度上有什么区别?为什么?
exists (select * from tmp_1 t where t.code=b.code);’应为
not
exists (select * from tmp_1 t where t.code=A.code);
not
exists (select * from tmp_1 t where t.code=A.code);