Set autotrace on eXPlain
alter session set optimizer_goal = choose;
select * from emp where sal < 1200;
PLAN
SELECT STATEMENT (OPTIMIZER=CHOOSE) (COST=62) (ROWS=99)
TABLE Access FULL EMP (COST=62) (ROWS=99)
现在,我们要使用FIRST_ROWS最优化来进行相同的查询工作。
alter session set optimizer_goal = first_rows;
select * from emp where sal < 1200;
The explain plan is now transformed to:
PLAN
SELECT STATEMENT (OPTIMIZER=FIRST_ROWS) (COST=102)
TABLE ACCESS BY INDEX ROWID EMP (COST=102) (ROWS=99)
INDEX RANGE SCAN SA L_IDX (COST=2) (ROWS=99)