您的位置:首页 > 数据库 > Oracle

oracle sql调优学习笔记(二)RBO Query Tuning 之Row cache order

2011-08-12 15:48 471 查看
If two access methods have the same rank, then the RBO makes an arbitrary decision:

SQL> conn scott/tiger@ipradev;

Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.5.0

Connected as scott

SQL> create table emp_temp as select * from emp;

Table created

SQL> desc emp_temp;

Name Type Nullable Default Comments

--------- ------------ -------- ------- --------

EMPNO NUMBER(4) Y

ENAME VARCHAR2(10) Y

JOB VARCHAR2(9) Y

MGR NUMBER(4) Y

HIREDATE DATE Y

SAL NUMBER(7,2) Y

COMM NUMBER(7,2) Y

DEPTNO NUMBER(2) Y

ISINSPECT NUMBER Y

SQL> select count(*) from emp_temp;

COUNT(*)

----------

15

SQL> create index idx_mgr on emp_temp(mgr);

Index created

SQL> create index idx_deptno on emp_temp(deptno);

Index created

SQL> alter session set optimizer_mode='RULE';

Session altered

SQL> explain plan for select * from emp_temp where mgr>100 and deptno>100;

Explained

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT

--------------------------------------------------------------------------------

Plan hash value: 3940654962

--------------------------------------------------

| Id | Operation | Name |

--------------------------------------------------

| 0 | SELECT STATEMENT | |

|* 1 | TABLE ACCESS BY INDEX ROWID| EMP_TEMP |

|* 2 | INDEX RANGE SCAN | IDX_DEPTNO |

--------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

1 - filter("MGR">100)

2 - access("DEPTNO">100)

Note

-----

- rule based optimizer used (consider using cbo)

19 rows selected

SQL> drop index idx_mgr;

Index dropped

SQL> create index idx_mgr on emp_temp(mgr);

Index created

SQL> explain plan for select * from emp_temp where mgr>100 and deptno>100;

Explained

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT

--------------------------------------------------------------------------------

Plan hash value: 2048646427

------------------------------------------------

| Id | Operation | Name |

------------------------------------------------

| 0 | SELECT STATEMENT | |

|* 1 | TABLE ACCESS BY INDEX ROWID| EMP_TEMP |

|* 2 | INDEX RANGE SCAN | IDX_MGR |

------------------------------------------------

Predicate Information (identified by operation id):

---------------------------------------------------

1 - filter("DEPTNO">100)

2 - access("MGR">100)

Note

-----

- rule based optimizer used (consider using cbo)

19 rows selected

第一次- filter("MGR">100),第二次- filter("DEPTNO">100),可见是arbitrary
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: