zoukankan      html  css  js  c++  java
  • 查看Oracle SQL执行计划的常用方式

    在查看SQL执行计划的时候有很多方式

    我常用的方式有三种

    SQL> explain plan for
    2 select * from scott.emp where ename='KING';

    已解释。

    第一种 最常用的

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

    Plan hash value: 3956160932
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     1 |    38 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     1 |    38 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("ENAME"='KING')
    
    已选择13行。

    第二种

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

    Plan hash value: 2637181423
    
    ---------------------------------------------------
    | Id  | Operation          | Name        | E-Rows |
    ---------------------------------------------------
    |   0 | DELETE STATEMENT   |             |        |
    |   1 |  DELETE            | PLAN_TABLE$ |        |
    |*  2 |   TABLE ACCESS FULL| PLAN_TABLE$ |      1 |
    ---------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       2 - filter("STATEMENT_ID"=:1)
    
    Note
    -----
       - dynamic sampling used for this statement (level=2)
       - Warning: basic plan statistics not available. These are only collected when:
           * hint 'gather_plan_statistics' is used for the statement or
           * parameter 'statistics_level' is set to 'ALL', at session or system level
    
    
    已选择26行。

    第三种

    SQL> select * from table(dbms_xplan.display(null,null,'ADVANCED -PROJECTION'));

    Plan hash value: 3956160932
    
    --------------------------------------------------------------------------
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    --------------------------------------------------------------------------
    |   0 | SELECT STATEMENT  |      |     1 |    38 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |     1 |    38 |     3   (0)| 00:00:01 |
    --------------------------------------------------------------------------
    
    Query Block Name / Object Alias (identified by operation id):
    -------------------------------------------------------------
    
       1 - SEL$1 / EMP@SEL$1
    
    Outline Data
    -------------
    
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "EMP"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          DB_VERSION('11.2.0.1')
          OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
      */
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter("ENAME"='KING')
    
    已选择32行。
  • 相关阅读:
    用Jetpack的Site Accelerator为网站CDN加速
    习惯了安逸的日子永远不知道折腾了才叫人生
    谷歌2019年最热门搜索词榜单公布
    如何隐藏WooCommerce Shop Page页面的标题
    woocommerce调用分类描述另一种方法
    修改woocommerce列表产品显示数量
    centos用手机号无法登入安全狗的解决方法
    centos安装安全狗5步就能完成
    centos安装安全狗提示Need system command 'locate' to install safedog for linux的解决方法
    yoast breadcrumb面包屑导航修改去掉product
  • 原文地址:https://www.cnblogs.com/SUN-PH/p/4837490.html
Copyright © 2011-2022 走看看