NL: 向量I/O 把原先的一批单块读组合起来,用一个向量I/O去批量处理。
笛卡尔连接 MERGE JOIN CARTESIAN: 大部分情况为SQL中漏掉连接条件。
反连接:外部WHERE 条件中NOT EXISTS ,NOT IN 或是<>ALL的子查询转成对应的反连接。
NOT EXISTS和<>ALL对NULL值敏感,一但子查询中有NULL,整个结果都是NULL。
半连接:会去重复。找到一条合条件的记录就停止搜索被驱动表。把外部WHERE 中含有EXISTS,IN或是=ANY的子查询转换成半连接。
create table t21(col1 number,col2 varchar2(1));
create table t22(col2 varchar2(1),col3 varchar2(2));
insert into t21 values(1,'A');
insert into t21 values(2,'B');
insert into t21 values(3,'C');
insert into t22 values('A','A2');
insert into t22 values('B','B2');
insert into t22 values('C','C2');
COMMIT;
create index indx_t2 on t22(col2);
select /*+ ordered use_nl(t22)*/t21.col1,t21.col2,t22.col3from t21,t22 where t21.col2 = t22.col2;
select /*+ optimizer_features_enable('9.2.0') ordereduse_nl(t22)*/t21.col1,t21.col2,t22.col3 from t21,t22 where t21.col2 = t22.col2;
select * from t21 where col2 not in(select col2 from t22);
insert into t21 values(4,null);
update t22 set col2 = 'D' where col3 ='C2';
commit;
insert into t22 values(null,'E2');
commit;
select * from t21 where col2 not in (select col2 from t22);
select * from t21 where col2 <> all (select col2 fromt22);
select * from t21 where not exists (select 1 from t22 wherecol2 =t21.col2);