select t.*
,t2.c1
,t3.c2
from t
,t2
,t3
where t.key1 = t2.key1(+)
and t.key2 = t3.key2(+);
또는
select t.*
,( select c1
from t2
where t2.key1 = t.key1 ) c1
,( select c2
from t3
where t3.key2 = t.key2 ) c2
from t;
create table t1 as select * from all_objects;
create table t2 as select * from all_objects where rownum <= 15000;
alter table t1 add constraint t1_pk primary key(object_id);
alter table t2 add constraint t2_pk primary key(object_id);
analyze table t1 compute statistics
for table for all indexes for all indexed columns;
analyze table t2 compute statistics
for table for all indexes for all indexed columns;
create or replace function get_data( p_object_id in number ) return varchar2
is
l_object_name t2.object_name%type;
begin
select object_name into l_object_name
from t2
where object_id = p_object_id;
return l_object_name;
exception
when no_data_found then
return NULL;
end;
/
set serveroutput on size 1000000;
begin
runstats_pkg.rs_start;
for x in ( select a.object_id
,a.object_name oname1
,b.object_name oname2
from t1 a
,t2 b
where a.object_id = b.object_id(+) )
loop
null;
end loop;
runstats_pkg.rs_middle;
for x in ( select object_id
,object_name oname1
,get_data(object_id) oname2
from t1 )
loop
null;
end loop;
runstats_pkg.rs_stop;
end;
/
방법1 | 방법2 | 차이 | |
---|---|---|---|
래치 합계 | 20225 | 546188 | 525963 |
- 강좌 URL : http://www.gurubee.net/lecture/3457
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.