设为首页 收藏本站
查看: 266|回复: 0

[经验分享] 关于oracle11g与12C只放图简单测试

[复制链接]
发表于 2015-12-18 09:12:34 | 显示全部楼层 |阅读模式
oracle 11g中小测:  SQL> create table tab(a number,b number);
  
  
  Table created.
  
  
  SQL> insert into tab select rownum,rownum from dual connect by level
  
  
  10000 rows created.
  
  
  SQL> update tab set b=5 where b between 6 and 9995;
  
  
  9990 rows updated.
  
  
  SQL> commit;
  
  
  Commit complete.
  
  
  SQL> show user
  USER is "GUIJIAN"
  SQL> create index tab_b_idx on tab(b);
  
  
  Index created.
  
  
  SQL> exec dbms_stats.gather_table_stats('HR','TAB',cascade=>true,method_opt=>'FOR COLUMNS B>
  
  
  SQL> 
  SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true,method_opt=>'FOR COLUMNS B>
  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> SET LINE 120 PAGESIZE 9999
  SQL> COL TABLE_NAME FOR A40
  SQL> COL COLUMN_NAME FOR A30
  SQL> select TABLE_NAME,COLUMN_NAME,ENDPOINT_NUMBER,ENDPOINT_VALUE from user_tab_histograms where TABLE_NAME='TAB';
  
  
  TABLE_NAME COLUMN_NAMEENDPOINT_NUMBER ENDPOINT_VALUE
  ---------------------------------------- ------------------------------ --------------- --------------
  TAB B      0      1
  TAB B      1  10000
  
  
  SQL> SET AUTOT TRACEONLY
  SQL> select * from tab where b=5;
  
  
  9991 rows selected.
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 157166354
  
  
  -----------------------------------------------------------------------------------------------------------
  |>
  -----------------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT                     |                                      |  1000   |  7000 |4   (0)            | 00:00:01 |
  |   1 |  RESULT CACHE                            | fthfr4cg5hx1d9xyqptnrkvasm |      |           |       |              |
  |   2 |   TABLE ACCESS BY INDEX ROWID| TAB                                |  1000  |  7000  |4   (0)            | 00:00:01 |
  |*  3 |    INDEX RANGE SCAN                 | TAB_B_IDX                      |  1000  |          |2   (0)            | 00:00:01 |
  -----------------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     3 - access("B"=5)
  
  
  Result Cache Information (identified by operation>
  ------------------------------------------------------
  
  
     1 - column-count=2; dependencies=(GUIJIAN.TAB); attributes=(ordered); name="select * from tab where b=5"
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
         1369  consistent gets
    0  physical reads
    0  redo>
       212182  bytes sent via SQL*Net to client
         7846  bytes received via SQL*Net from client
   668  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
         9991  rows processed
  
  
  SQL> SET AUTOT OFF
  SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true);
  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> SET AUTOT TRACEONLY
  SQL> select * from tab where b=1;
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 157166354
  
  
  -----------------------------------------------------------------------------------------------------------
  |>
  -----------------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT                                             |                      |1         |7         |2   (0)| 00:00:01 |
  |   1 |  RESULT CACHE     | 8fvut8ab0yprn28nk7n8zfgqxx |                      |            |           |           |
  |   2 |   TABLE ACCESS BY INDEX ROWID                        | TAB                |1         |7         |2   (0)| 00:00:01 |
  |*  3 |    INDEX RANGE SCAN                                         | TAB_B_IDX      |1         |            |1   (0)| 00:00:01 |
  -----------------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     3 - access("B"=1)
  
  
  Result Cache Information (identified by operation>
  ------------------------------------------------------
  
  
     1 - column-count=2; dependencies=(GUIJIAN.TAB); attributes=(ordered); name="select * from tab where b=1"
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
    4  consistent gets
    0  physical reads
    0  redo>
   585  bytes sent via SQL*Net to client
   520  bytes received via SQL*Net from client
    2  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
    1  rows processed
  
  
  SQL> select * from tab where  b=5;
  
  
  9991 rows selected.
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 1995730731
  
  
  -------------------------------------------------------------------------------------------------
  |>
  -------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT           |            |  9991 | 69937 |     7   (0)| 00:00:01 |
  |   1 |  RESULT CACHE                   | 2g2jk82jgbp6tfn51zxvwrg9ms |||     ||
  |*  2 |   TABLE ACCESS FULL        | TAB        |  9991 | 69937 |     7   (0)| 00:00:01 |
  -------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     2 - filter("B"=5)
  
  
  Result Cache Information (identified by operation>
  ------------------------------------------------------
  
  
     1 - column-count=2; dependencies=(GUIJIAN.TAB); name="select * from tab where  b=5"
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
   687  consistent gets
    0  physical reads
    0  redo>
       212182  bytes sent via SQL*Net to client
         7846  bytes received via SQL*Net from client
   668  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
         9991  rows processed
  SQL> /
  
  
  TABLE_NAME COLUMN_NAMEENDPOINT_NUMBER ENDPOINT_VALUE
  ---------------------------------------- ------------------------------ --------------- --------------
  TAB B      1      1
  TAB B      2      2
  TAB B      3      3
  TAB B      4      4
  TAB B   9995      5
  TAB B   9996   9996
  TAB B   9997   9997
  TAB B   9998   9998
  TAB B   9999   9999
  TAB B  10000  10000
  TAB A      0      1
  TAB A      1  10000
  
  
  12 rows selected.
  
  
SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true,method_opt=>'FOR COLUMNS B>  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> select TABLE_NAME,COLUMN_NAME,ENDPOINT_NUMBER,ENDPOINT_VALUE from user_histograms where table_name='TAB';
  
  
  TABLE_NAME COLUMN_NAMEENDPOINT_NUMBER ENDPOINT_VALUE
  ---------------------------------------- ------------------------------ --------------- --------------
  TAB B      0      1
  TAB B      7      5
  TAB B      8  10000
  TAB A      0      1
  TAB A      1  10000
  
  
  SQL> 
  
  
  12C中小测试:
  SQL> update tab set b=5 where b between 6 and 9995;
  
  
  9990 rows updated.
  
  
  SQL> commit;
  
  
  Commit complete.
  
  
  SQL> create index tab_b_idx on tab(b);
  
  
  Index created.
  
  
  SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true,method_opt=>'FOR COLUMNS B>
  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> select TABLE_NAME,COLUMN_NAME,ENDPOINT_NUMBER,ENDPOINT_VALUE from user_tab_histograms where TABLE_NAME='TAB';
  
  
  TABLE_NAME       COLUMN_NAME      ENDPOINT_NUMBER ENDPOINT_VALUE
  ------------------------------ ------------------------------ --------------- --------------
  TAB       B    0   1
  TAB       B    1       10000
  
  
  SQL> set autot traceonly
  SQL> select * from tab where b=5;
  
  
  9991 rows selected.
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 3198923545
  
  
  -------------------------------------------------------------------------------------------------
  |>
  -------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT    ||   100 |   700 |     2   (0)| 00:00:01 |
  |   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TAB|   100 |   700 |     2   (0)| 00:00:01 |
  |*  2 |   INDEX RANGE SCAN    | TAB_B_IDX |  1000 ||     1   (0)| 00:00:01 |
  -------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     2 - access("B"=5)
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
         1370  consistent gets
    0  physical reads
    0  redo>
       249496  bytes sent via SQL*Net to client
         7878  bytes received via SQL*Net from client
   668  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
         9991  rows processed
  
  
  SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true);
  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> select * from tab where b=1;
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 3198923545
  
  
  -------------------------------------------------------------------------------------------------
  |>
  -------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT    ||     1 |     7 |     2   (0)| 00:00:01 |
  |   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TAB|     1 |     7 |     2   (0)| 00:00:01 |
  |*  2 |   INDEX RANGE SCAN    | TAB_B_IDX |     1 ||     1   (0)| 00:00:01 |
  -------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     2 - access("B"=1)
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
    4  consistent gets
    0  physical reads
    0  redo>
   605  bytes sent via SQL*Net to client
   552  bytes received via SQL*Net from client
    2  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
    1  rows processed
  
  
  SQL> select * from tab where  b=5;
  
  
  9991 rows selected.
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 3198923545
  
  
  -------------------------------------------------------------------------------------------------
  |>
  -------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT    ||   101 |   707 |     2   (0)| 00:00:01 |
  |   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TAB|   101 |   707 |     2   (0)| 00:00:01 |
  |*  2 |   INDEX RANGE SCAN    | TAB_B_IDX |||     1   (0)| 00:00:01 |
  -------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     2 - access("B"=5)
  
  
  
  
  Statistics
  ----------------------------------------------------------
    1  recursive calls
    0  db block gets
         1370  consistent gets
    0  physical reads
    0  redo>
       249496  bytes sent via SQL*Net to client
         7878  bytes received via SQL*Net from client
   668  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
         9991  rows processed
  
  
  SQL> set autot off
  SQL> select TABLE_NAME,COLUMN_NAME,ENDPOINT_NUMBER,ENDPOINT_VALUE from user_histograms where table_name='TAB';
  
  
  TABLE_NAME       COLUMN_NAME      ENDPOINT_NUMBER ENDPOINT_VALUE
  ------------------------------ ------------------------------ --------------- --------------
  TAB       B    1   1
  TAB       B    2   2
  TAB       B    3   3
  TAB       B    4   4
  TAB       B 9995   5
  TAB       B 99969996
  TAB       B 99979997
  TAB       B 99989998
  TAB       B 99999999
  TAB       B10000       10000
  TAB       A    0   1
  TAB       A    1       10000
  
  
  12 rows selected.
  
  
  SQL> exec dbms_stats.gather_table_stats('GUIJIAN','TAB',cascade=>true,method_opt=>'FOR COLUMNS B>
  
  
  PL/SQL procedure successfully completed.
  
  
  SQL> select TABLE_NAME,COLUMN_NAME,ENDPOINT_NUMBER,ENDPOINT_VALUE from user_histograms where table_name='TAB';
  
  
  TABLE_NAME       COLUMN_NAME      ENDPOINT_NUMBER ENDPOINT_VALUE
  ------------------------------ ------------------------------ --------------- --------------
  TAB       B    1   1
  TAB       B    2   2
  TAB       B    3   3
  TAB       B    4   4
  TAB       B 9995   5
  TAB       B 99969998
  TAB       B 99979999
  TAB       B 9998       10000
  TAB       A    0   1
  TAB       A    1       10000
  
  
  10 rows selected.
  
  
  SQL> set autot traceonly
  SQL> select * from tab where b=5;
  
  
  9991 rows selected.
  
  
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 3198923545
  
  
  -------------------------------------------------------------------------------------------------
  |>
  -------------------------------------------------------------------------------------------------
  |   0 | SELECT STATEMENT    ||   101 |   707 |     2   (0)| 00:00:01 |
  |   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| TAB|   101 |   707 |     2   (0)| 00:00:01 |
  |*  2 |   INDEX RANGE SCAN    | TAB_B_IDX |||     1   (0)| 00:00:01 |
  -------------------------------------------------------------------------------------------------
  
  
  Predicate Information (identified by operation>
  ---------------------------------------------------
  
  
     2 - access("B"=5)
  
  
  
  
  Statistics
  ----------------------------------------------------------
    0  recursive calls
    0  db block gets
         1370  consistent gets
    0  physical reads
    0  redo>
       249496  bytes sent via SQL*Net to client
         7878  bytes received via SQL*Net from client
   668  SQL*Net roundtrips to/from client
    0  sorts (memory)
    0  sorts (disk)
         9991  rows processed
  
  
  SQL> 
  
  
  差异:11g与12C在执行计划中的rows中评估值存在较大差异......下班了,待续............
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-152759-1-1.html 上篇帖子: oracle 9i 手动建库 下篇帖子: oracle ash性能报告的使用方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表