首頁 > 資料庫 > mysql教程 > Oracle查看sql执行计划和统计信息

Oracle查看sql执行计划和统计信息

WBOY
發布: 2016-06-07 17:04:25
原創
917 人瀏覽過

--获取sql的执行计划以及统计信息,不显示查询信息 SQLgt; set autotrace traceonly;SQLgt; select * from test;执行计划-----

Linux公社

首页 → 数据库技术

背景:

阅读新闻

Oracle查看sql执行计划和统计信息

[日期:2011-08-31] 来源:Linux社区  作者:AnyJack [字体:]

--获取sql的执行计划以及统计信息,不显示查询信息
SQL> set autotrace traceonly;
SQL> select * from test;
执行计划
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     2 |   130 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| TEST |     2 |   130 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------
Note
-----
   - dynamic sampling used for this statement
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          8  consistent gets
          6  physical reads
          0  redo size
        523  bytes sent via SQL*Net to client
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          2  rows processed
==============================================================
--只显示统计信息
SQL> set autot traceonly stat;
SQL> select * from test;
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          8  consistent gets
          0  physical reads
          0  redo size
        523  bytes sent via SQL*Net to client
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          2  rows processed
==============================================================
--只显示执行计划
SQL> set autot traceonly exp;
SQL> select * from test;
执行计划
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     2 |   130 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| TEST |     2 |   130 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------
Note
-----
   - dynamic sampling used for this statement
==============================================================
--开启sql跟踪,显示查询结果和执行计划,以及统计信息
SQL> set autot on;
SQL> select * from test;
      T_ID   T_NAME
-------------------------------------------------------------------------------------
         1      t1
         2      t2
执行计划
----------------------------------------------------------
Plan hash value: 1357081020
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     2 |   130 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| TEST |     2 |   130 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------
Note
-----
   - dynamic sampling used for this statement
统计信息
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          8  consistent gets
          0  physical reads
          0  redo size
        523  bytes sent via SQL*Net to client
        416  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          2  rows processed
==============================================================
--关闭sql跟踪,只显示查询结果
SQL> set autot off;
SQL> select * from test;
      T_ID    T_NAME
-------------------------------------------------------
         1        t1
         2        t2

linux

  • 0
  • 用SAS宏实现Oracle中的decode函数

    Oracle RMAN 丢失归档日志:ORA-19625: error identifying file

    相关资讯       Oracle教程 

    图片资讯      

    本文评论   查看全部评论 (0)

    评论声明

    最新资讯

    本周热门

    來源:php.cn
    本網站聲明
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
    最新問題
    熱門教學
    更多>
    最新下載
    更多>
    網站特效
    網站源碼
    網站素材
    前端模板