OPTIMIZER_INDEX_CACHING
책 429~431 방법대로 테스트를 해 보았으나 동일한 쿼리 계획을 얻음
create or replace procedure oltp_style
as
l_rec big_table%rowtype;
l_n number;
begin
for i in 1 .. 10000
loop
l_n := trunc( dbms_random.value( 2, 1000000 ) );
select * into l_rec from big_table where id = l_n;
end loop;
end;
/
create or replace procedure dw_style
as
l_n number;
begin
select count(*) into l_n
from (
select /*+ USE_HASH(t1,t2)
FULL(t1) FULL(t2)
NOPARALLEL(t1) NOPARALLEL(t2) */
t1.data_object_id, t2.data_object_id
from big_table t1, big_Table t2
where t1.id = t2.id
);
end;
/
exec dbms_stats.drop_stat_table( user, 'SYSTEM_STATS' );
exec dbms_stats.create_stat_table( user, 'SYSTEM_STATS' );
exec dbms_stats.delete_system_stats;
declare
n number;
begin
oltp_style;
dbms_job.submit( n, 'oltp_style;' );
dbms_job.submit( n, 'oltp_style;' );
dbms_job.submit( n, 'oltp_style;' );
commit;
dbms_stats.gather_system_stats( gathering_mode => 'START',
stattab => 'SYSTEM_STATS',
statid => 'OLTP' );
select count(*) into n from user_jobs where what = 'oltp_style;';
while ( n > 0 )
loop
dbms_lock.sleep(5);
select count(*) into n from user_jobs where what = 'oltp_style;';
end loop;
dbms_stats.gather_system_stats( gathering_mode => 'STOP',
stattab => 'SYSTEM_STATS',
statid => 'OLTP' );
end;
/
declare
n number;
begin
dw_style;
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'dw_style;' );
commit;
end;
/
declare
n number;
begin
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'dw_style;' );
dbms_job.submit( n, 'oltp_style;' );
dbms_job.submit( n, 'oltp_style;' );
dbms_job.submit( n, 'oltp_style;' );
commit;
end;
/
alter system flush shared_pool;
alter session set optimizer_index_cost_adj=100;
alter session set optimizer_index_caching=0;
begin
dbms_stats.import_system_stats
( stattab => 'SYSTEM_STATS', statid => 'OLTP', statown => user );
end;
/
set autotrace traceonly explain
select /* TAGGED OLTP */ *
from big_table t1, big_table t2
where t1.id = t2.id
and t2.id between 50 and 55;
SELECT * FROM SYS.AUX_STATS$
SREADTIM | 단일블록I/O를 읽는데 걸린 시간 (단위: 밀리초) |
MREADTIM | 다중블록을 읽는데 걸린시간 (단위: 밀리초) |
CPUSPEED | 초당 사용가능한 사이클(단위: 밀리초), 상대적인 CPU속도 |
MBRC | 관찰된 평균다중 블록 읽기 횟수 |
MAXTHR | 최대 I/O 처리량 (단위: 바이트/초) |
SLAVETHR | 평균 I/O 종속 I/O처리량 (단위: 바이트/초) |