where 절에 인덱스 컬럼을 가공하게 되면 full table scan을 하게 됩니다.

▣ 관련 예제

튜닝전

select /*+ gather_plan_statistics */ ename, sal
from emp
where sal *12 = 36000;

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

튜닝 후

select /*+ gather_plan_statistics */ ename, sal
from emp
where sal = 36000/12;

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

설명: 버퍼의 갯수가 7개에서 2개로 줄었습니다.

문제 7. 아래의 sql을 튜닝하시오!

create index emp_ename on emp(ename);
create index emp_sal on emp(sal);

튜닝전

select /*+ gather_plan_statistics */  ename, sal, job
              from  emp
              where   ename || sal   = 'SCOTT3000';
              
              select  * from  table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'))

튜닝 후

select /*+ gather_plan_statistics */  ename, sal, job
              from  emp
              where   ename = 'SCOTT'
              and sal=3000;
select  * from  table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'))       

문제 8 아래의 sql을 실행하시오.

create  index  emp_job  on  emp(job);
create  index  emp_deptno  on  emp(deptno);

튜닝전: