튜닝전

@demo

create index emp_sal on emp(sal)

select ename, sal
from emp
where sal like '30%';

select * from  table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));

튜닝후

create index emp_sal_tochar
on  emp( to_char(sal) );
select  ename, sal
             from  emp
             where  sal  like  '30%';

select * from  table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));

문제 14. 아래의 환경을 만들고 아래의 sql을 튜닝하시오!

drop  table  emp9000;

create  table  emp9000
( ename   varchar2(10),
   sal    varchar2(10) );

insert   into  emp9000  values('scott', '3000');
insert   into  emp9000  values('smith', '1000');
insert   into  emp9000  values('allen', '2000');
commit;

create  index emp9000_sal  on  emp9000(sal);

select  ename, sal
              from  emp9000
              where sal = 3000;

튜닝후

select  ename, sal
              from  emp9000
              where sal = '3000';
              
select * from  table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));

설명: sql을 재작성 할 수 있으면 sql 을 재작성하는게 먼저입니다.

인덱스를 만드는 것은 아주 값비싼 작업입니다.

현업 튜닝 사례

튜닝 날짜  :

튜  너  :   유연수 차장

튜닝 내용 :  8월 4일 16시 11분 부산지원 청구 1호기에서 DB FILE SCATTRED READ 대기 이벤트를 일으키면서 47초 이상 수행되는 SQL 발견하여 관련된 SQL 튜닝.

(튜닝전 47초 --> 튜닝후 1초)

☞  문제의 SQL 을 수행한 프로그램 정보및 DB 유져정보