[bbk5307]第76集 第9章 -数据库性能维护 03
/*
Oracle optimizer 執(zhí)行選擇方式原理分析
*/
select * from emp where empno=7369;
oracle在執(zhí)行查詢計(jì)劃的時(shí)候,并不是說要執(zhí)行一次全表掃描和一次索引掃描之后,來決定到底是走哪一條路?而是通過數(shù)據(jù)字典里的統(tǒng)計(jì)數(shù)據(jù)信息,來分析判斷到底是走那一條執(zhí)行計(jì)劃.
|-full table
|-index scan
data_table---> num_rows(10000)-1/10000
num_rows(10000)-1/2
SQL> create table emp1 as select * from emp;Table created.SQL> select table_name,num_rows from user_tables;TABLE_NAME NUM_ROWS ------------------------------ ---------- C_DEPT 0 C_EMP 0 T 107 M 3 EMP 107 DEPT 115 LOG 1249 LOG_LW 1438 EMP19 rows selected.SQL> select count(*) from emp1;COUNT(*) ----------107SQL> analyze table emp1 compute statistics;Table analyzed.SQL> select table_name,num_rows from user_tables;TABLE_NAME NUM_ROWS ------------------------------ ---------- C_DEPT 0 C_EMP 0 T 107 M 3 EMP 107 DEPT 115 LOG 1249 LOG_LW 1438 EMP1 1079 rows selected. 表統(tǒng)計(jì)數(shù)據(jù)分析?收集統(tǒng)計(jì)信息命令
analyze table emp1 compute statistics;?有關(guān)表的統(tǒng)計(jì)信息:dba_tables
有關(guān)索引的統(tǒng)計(jì)信息:dba_indexes
有關(guān)列的統(tǒng)計(jì)信息:dba_tab_col_statistics
oracle 10g-11g之后的版本可以分析oracle本身對象的統(tǒng)計(jì)指標(biāo)信息,以及操作系統(tǒng)的通知指標(biāo)信息,從而能夠給我們提供更好的執(zhí)行計(jì)劃.
Optimizer Statistics Collection
- SQL performance tuning:Depends on collection of accurate statistics
- Optimizer statistics:
- -Object statistics
- -Operating system statistics
- Ways to collect statistics:
- -Automatically:Automatic Maintenance Tasks
- -Manually:DBMS_STATS package
- -By setting database initialization parameters
- -By importing statistics from another database
轉(zhuǎn)載于:https://www.cnblogs.com/arcer/archive/2013/06/03/3115528.html
總結(jié)
以上是生活随笔為你收集整理的[bbk5307]第76集 第9章 -数据库性能维护 03的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据挖掘中特征选择算法的基本综述
- 下一篇: 在navicat中新建数据库