https://blog.csdn.net/m15217321304/article/details/80672385 

有时候在优化SQL语句时,需要得到详细sql的相关信息,这个时候可以借助dbms_sqltune工具实现,还有一种情况,有时候知道SQL_ID也能通过v$sqlarea、v$sql等视图查看到sql_text,但是sql_text的内容看到的不全,这个时候也可以借助dbms_sqltune工具来展示完整的SQL_TEXT。

Oracle Database 11g: Real-Time SQL Monitoring
      Real-Time SQL Monitoring, introduced in Oracle Database 11g, provides a very effective way to identify run-time performance problems with resource intensive long-running and parallel SQL statements. Interactive Enterprise Manager screens display details of SQL execution using new, fine-grained SQL statistic that are tracked out-of-the-box with no performance penalty to production systems. Statistics at each step of the execution plan are tracked by key performance metrics, including elapsed time, CPU time, number of reads and writes, I/O wait time and various other wait times. This allows DBAs to analyze SQL execution more deeply than previously possible and decide on the most appropriate tuning strategies for monitored SQL statements.

The real-time SQL monitoring feature of Oracle Database enables you to monitor the performance of SQL statements while they are executing. By default, SQL monitoring automatically starts when a SQL statement runs parallel, or when it has consumed at least 5 seconds of CPU or I/O time in a single execution.

 

oracle 11g 增加了实时监控SQL性能的工具dbms_sqltune, 单次执行时间超过5s的语句会被记录到v$sql_monitor中,下面是关于v$sql_monitor视图的介绍

V$SQL_MONITOR
V$SQL_MONITOR displays SQL statements whose execution have been (or are being) monitored by Oracle. An entry is created in V$SQL_MONITOR every time the execution of a SQL statement is being monitored. SQL monitoring is automatically started when a SQL statement runs parallel or when it has consumed at least 5 seconds of CPU or I/O time.
When the SQL statement being monitored is executing, statistics in V$SQL_MONITOR are generally refreshed in near real time, once every second. Once the execution ends, monitoring information is not deleted immediately. Instead, it is kept in V$SQL_MONITOR for at least one minute. The entry will eventually be deleted to reclaim its space as new statements are monitored.

实验过程

1、首先查询v$sql_monitor视图

  1.  
    SQL> select sid, sql_id, status, username,sql_text from v$sql_monitor where username = 'SCOTT';
  2.  
     
  3.  
    SID SQL_ID STATUS USERNAME SQL_TEXT
  4.  
    ---------- ------------- ------------------- --------------- ----------------------------------------
  5.  
    142 7rnnuxvqm98y2 DONE (ERROR) SCOTT declare
  6.  
     
  7.  
    Elapsed: 00:00:00.00
  8.  
    SQL>
  9.  
     

这个时候scott用户被监控的sql只有一个。

2、连接到scott用户,执行一个SQL,执行消耗时间小于5s

  1.  
    SQL> show user
  2.  
    USER is "SCOTT"
  3.  
    SQL> set timing on
  4.  
    SQL> select count(*) from t;
  5.  
     
  6.  
    COUNT(*)
  7.  
    ----------
  8.  
    14
  9.  
     
  10.  
    Elapsed: 00:00:00.00
  11.  
    SQL>

3、再次查询v$sql_monitor视图确认

  1.  
    SQL> select sid, sql_id, status, username,sql_text from v$sql_monitor where username = 'SCOTT';
  2.  
     
  3.  
    SID SQL_ID STATUS USERNAME SQL_TEXT
  4.  
    ---------- ------------- ------------------- --------------- ----------------------------------------
  5.  
    142 7rnnuxvqm98y2 DONE (ERROR) SCOTT declare
  6.  
     
  7.  
    Elapsed: 00:00:00.00
  8.  
    SQL>
  9.  
    SQL>

4、使用hit 再次查询表T

  1.  
    SQL> show user
  2.  
    USER is "SCOTT"
  3.  
    SQL> select /*+ monitor */ count(*) from t;
  4.  
     
  5.  
    COUNT(*)
  6.  
    ----------
  7.  
    14
  8.  
     
  9.  
    Elapsed: 00:00:00.00
  10.  
    SQL>

5、再次查询v$sql_monitor视图确认

  1.  
    SQL> select sid, sql_id, status, username,sql_text from v$sql_monitor where username = 'SCOTT';
  2.  
     
  3.  
    SID SQL_ID STATUS USERNAME SQL_TEXT
  4.  
    ---------- ------------- ------------------- --------------- ----------------------------------------
  5.  
    125 5zh82u75cjxzt DONE (ALL ROWS) SCOTT select /*+ monitor */ count(*) from t <======发现sql已经记录到了v$sql_monitor 视图里面
  6.  
    142 7rnnuxvqm98y2 DONE (ERROR) SCOTT declare
  7.  
     
  8.  
    Elapsed: 00:00:00.01
  9.  
    SQL>


6、使用DBMS_SQLTUNE.report_sql_monitor打印出完整的监控信息

  1.  
    FUNCTION REPORT_SQL_MONITOR RETURNS CLOB
  2.  
    Argument Name Type In/Out Default?
  3.  
    ------------------------------ ----------------------- ------ --------
  4.  
    SQL_ID VARCHAR2 IN DEFAULT
  5.  
    SESSION_ID NUMBER IN DEFAULT
  6.  
    SESSION_SERIAL NUMBER IN DEFAULT
  7.  
    SQL_EXEC_START DATE IN DEFAULT
  8.  
    SQL_EXEC_ID NUMBER IN DEFAULT
  9.  
    INST_ID NUMBER IN DEFAULT
  10.  
    START_TIME_FILTER DATE IN DEFAULT
  11.  
    END_TIME_FILTER DATE IN DEFAULT
  12.  
    INSTANCE_ID_FILTER NUMBER IN DEFAULT
  13.  
    PARALLEL_FILTER VARCHAR2 IN DEFAULT
  14.  
    PLAN_LINE_FILTER NUMBER IN DEFAULT
  15.  
    EVENT_DETAIL VARCHAR2 IN DEFAULT
  16.  
    BUCKET_MAX_COUNT NUMBER IN DEFAULT
  17.  
    BUCKET_INTERVAL NUMBER IN DEFAULT
  18.  
    BASE_PATH VARCHAR2 IN DEFAULT
  19.  
    LAST_REFRESH_TIME DATE IN DEFAULT
  20.  
    REPORT_LEVEL VARCHAR2 IN DEFAULT
  21.  
    TYPE VARCHAR2 IN DEFAULT
  22.  
    SQL_PLAN_HASH_VALUE NUMBER IN DEFAULT
  23.  
     
  24.  
    一般使用如下两种方式
  25.  
    1、SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') report FROM dual; -----生成文本
  26.  
    2、SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'active') report FROM dual; -----生成html格式
  27.  
     
  28.  
     
  29.  
    查询之前加上下面格式化下,输出结果会比较好看
  30.  
    SET LONG 1000000
  31.  
    SET LONGCHUNKSIZE 1000000
  32.  
    SET LINESIZE 1000
  33.  
    SET PAGESIZE 0
  34.  
    SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') report FROM dual;
  35.  
     
  36.  
    Enter value for sqlid: 5zh82u75cjxzt
  37.  
    old 1: SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') report FROM dual
  38.  
    new 1: SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '5zh82u75cjxzt', type => 'TEXT') report FROM dual
  39.  
    SQL Monitoring Report
  40.  
     
  41.  
    SQL Text
  42.  
    ------------------------------
  43.  
    select /*+ monitor */ count(*) from t
  44.  
     
  45.  
    Global Information
  46.  
    ------------------------------
  47.  
    Status : DONE (ALL ROWS)
  48.  
    Instance ID : 1
  49.  
    Session : SCOTT (125:17)
  50.  
    SQL ID : 5zh82u75cjxzt
  51.  
    SQL Execution ID : 16777216
  52.  
    Execution Started : 06/13/2018 00:57:03
  53.  
    First Refresh Time : 06/13/2018 00:57:03
  54.  
    Last Refresh Time : 06/13/2018 00:57:03
  55.  
    Duration : .000207s
  56.  
    Module/Action : SQL*Plus/-
  57.  
    Service : SYS$USERS
  58.  
    Program : sqlplus@QXY1.localdomain (TNS V1-V3)
  59.  
    Fetch Calls : 1
  60.  
     
  61.  
    Global Stats
  62.  
    =======================================
  63.  
    | Elapsed | Other | Fetch | Buffer |
  64.  
    | Time(s) | Waits(s) | Calls | Gets |
  65.  
    =======================================
  66.  
    | 0.00 | 0.00 | 1 | 2 |
  67.  
    =======================================
  68.  
     
  69.  
    SQL Plan Monitoring Details (Plan Hash Value=2966233522)
  70.  
    ==========================================================================================================================
  71.  
    | Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Activity | Activity Detail |
  72.  
    | | | | (Estim) | | Active(s) | Active | | (Actual) | (%) | (# samples) |
  73.  
    ==========================================================================================================================
  74.  
    | 0 | SELECT STATEMENT | | | | 1 | +0 | 1 | 1 | | |
  75.  
    | 1 | SORT AGGREGATE | | 1 | | 1 | +0 | 1 | 1 | | |
  76.  
    | 2 | TABLE ACCESS FULL | T | 14 | 3 | 1 | +0 | 1 | 14 | | |
  77.  
    ==========================================================================================================================
  78.  
     
  79.  
     
  80.  
    Elapsed: 00:00:00.07
  81.  
    SQL>


7、如果sql执行时间超过5s会自动记录到v$sql_monitor里面

  1.  
    SQL>
  2.  
    SQL> select count(*) from dba_extents;
  3.  
    《=======时间很长,还没有返回结果

8、查询v$sql_monitor视图确认

  1.  
    SQL> select sid, sql_id, status, username,sql_text from v$sql_monitor where username = 'SCOTT';
  2.  
    125 1f9jvntajsr7v EXECUTING SCOTT select count(*) from dba_extents 《=======状态是执行中
  3.  
    125 5zh82u75cjxzt DONE (ALL ROWS) SCOTT select /*+ monitor */ count(*) from t
  4.  
    142 7rnnuxvqm98y2 DONE (ERROR) SCOTT declare
  5.  
    v_num number;
  6.  
    begin
  7.  
    for i in 1..10000000 loop
  8.  
    select count(*) into v_num from test;
  9.  
    end loop;
  10.  
    end;
  11.  
     
  12.  
     
  13.  
    Elapsed: 00:00:00.00
  14.  
    SQL>

9、查询monitor信息

  1.  
    SQL> SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') report FROM dual;
  2.  
    Enter value for sqlid: 1f9jvntajsr7v
  3.  
    old 1: SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT') report FROM dual
  4.  
    new 1: SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '1f9jvntajsr7v', type => 'TEXT') report FROM dual
  5.  
    SQL Monitoring Report
  6.  
     
  7.  
    SQL Text
  8.  
    ------------------------------
  9.  
    select count(*) from dba_extents
  10.  
     
  11.  
    Global Information
  12.  
    ------------------------------
  13.  
    Status : EXECUTING
  14.  
    Instance ID : 1
  15.  
    Session : SCOTT (125:17)
  16.  
    SQL ID : 1f9jvntajsr7v
  17.  
    SQL Execution ID : 16777216
  18.  
    Execution Started : 06/13/2018 01:06:10
  19.  
    First Refresh Time : 06/13/2018 01:06:16
  20.  
    Last Refresh Time : 06/13/2018 01:08:16
  21.  
    Duration : 126s
  22.  
    Module/Action : SQL*Plus/-
  23.  
    Service : SYS$USERS
  24.  
    Program : sqlplus@QXY1.localdomain (TNS V1-V3)
  25.  
     
  26.  
    Global Stats
  27.  
    ===================================================================
  28.  
    | Elapsed | Cpu | IO | Other | Buffer | Read | Read |
  29.  
    | Time(s) | Time(s) | Waits(s) | Waits(s) | Gets | Reqs | Bytes |
  30.  
    ===================================================================
  31.  
    | 125 | 124 | 0.00 | 1.17 | 9772 | 76 | 12MB |
  32.  
    ===================================================================
  33.  
     
  34.  
    SQL Plan Monitoring Details (Plan Hash Value=2677681623)
  35.  
    =================================================================================================================================================================
  36.  
    | Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Mem | Activity | Activity Detail |
  37.  
    | | | | (Estim) | | Active(s) | Active | | (Actual) | | (%) | (# samples|
  38.  
    =================================================================================================================================================================
  39.  
    | 0 | SELECT STATEMENT | | | | | | 1 | | | | |
  40.  
    | 1 | SORT AGGREGATE | | 1 | | | | 1 | | | | |
  41.  
    | 2 | VIEW | DBA_EXTENTS | 458 | 3609 | | | 1 | | | | |
  42.  
    | 3 | UNION-ALL | | | | | | 1 | | | | |
  43.  
    | 4 | HASH JOIN | | 1 | 1803 | | | 1 | | | | |
  44.  
    | 5 | NESTED LOOPS | | 1 | 22 | | | 1 | | | | |
  45.  
    | 6 | TABLE ACCESS FULL | UET$ | 1 | 22 | | | 1 | | | | |
  46.  
    | 7 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | | | | | | | |
  47.  
    | 8 | VIEW | SYS_DBA_SEGS | 6853 | 1781 | | | | | | | |
  48.  
    | 9 | UNION-ALL | | | | | | | | | | |
  49.  
    | 10 | NESTED LOOPS | | 1 | 22 | | | | | | | |
  50.  
    | 11 | NESTED LOOPS OUTER | | 1 | 21 | | | | | | | |
  51.  
    | 12 | NESTED LOOPS | | 1 | 20 | | | | | | | |
  52.  
    | 13 | NESTED LOOPS | | 1 | 20 | | | | | | | |
  53.  
    | 14 | TABLE ACCESS FULL | UNDO$ | 18 | 2 | | | | | | | |
  54.  
    | 15 | TABLE ACCESS CLUSTER | SEG$ | 1 | 1 | | | | | | | |
  55.  
    | 16 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | 1 | | | | | | | | |
  56.  
    | 17 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | | | | | | | |
  57.  
    | 18 | INDEX RANGE SCAN | I_USER2 | 1 | 1 | | | | | | | |
  58.  
    | 19 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | | | | | | | |
  59.  
    | 20 | INDEX UNIQUE SCAN | I_TS# | 1 | | | | | | | | |
  60.  
    | 21 | NESTED LOOPS | | 6852 | 1759 | | | | | | | |
  61.  
    | 22 | VIEW | VW_JF_SET$CB2157A3 | 6852 | 1758 | | | | | | | |
  62.  
    | 23 | UNION-ALL | | | | | | | | | | |
  63.  
    | 24 | HASH JOIN RIGHT OUTER | | 6851 | 1701 | | | | | | | |
  64.  
    | 25 | INDEX FULL SCAN | I_USER2 | 103 | 1 | | | | | | | |
  65.  
    | 26 | HASH JOIN | | 6851 | 1700 | | | | | | | |
  66.  
    | 27 | VIEW | SYS_OBJECTS | 10141 | 1581 | | | | | | | |
  67.  
    | 28 | UNION-ALL | | | | | | | | | | |
  68.  
    | 29 | TABLE ACCESS FULL | TAB$ | 3007 | 393 | | | | | | | |
  69.  
    | 30 | TABLE ACCESS FULL | TABPART$ | 155 | 4 | | | | | | | |
  70.  
    | 31 | TABLE ACCESS FULL | CLU$ | 10 | 392 | | | | | | | |
  71.  
    | 32 | TABLE ACCESS FULL | IND$ | 5326 | 393 | | | | | | | |
  72.  
    | 33 | TABLE ACCESS FULL | INDPART$ | 302 | 5 | | | | | | | |
  73.  
    | 34 | TABLE ACCESS FULL | LOB$ | 1307 | 389 | | | | | | | |
  74.  
    | 35 | TABLE ACCESS FULL | TABSUBPART$ | 32 | 2 | | | | | | | |
  75.  
    | 36 | TABLE ACCESS FULL | INDSUBPART$ | 1 | 2 | | | | | | | |
  76.  
    | 37 | TABLE ACCESS FULL | LOBFRAG$ | 1 | 2 | | | | | | | |
  77.  
    | 38 | MERGE JOIN CARTESIAN | | 50994 | 117 | | | | | | | |
  78.  
    | 39 | NESTED LOOPS | | 1 | 56 | | | | | | | |
  79.  
    | 40 | TABLE ACCESS FULL | SEG$ | 1 | 55 | | | | | | | |
  80.  
    | 41 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | | | | | | | |
  81.  
    | 42 | INDEX UNIQUE SCAN | I_TS# | 1 | | | | | | | | |
  82.  
    | 43 | BUFFER SORT | | 75479 | 116 | | | | | | | |
  83.  
    | 44 | INDEX FAST FULL SCAN | I_OBJ1 | 75479 | 61 | | | | | | | |
  84.  
    | 45 | NESTED LOOPS | | 1 | 57 | | | | | | | |
  85.  
    | 46 | NESTED LOOPS OUTER | | 1 | 56 | | | | | | | |
  86.  
    | 47 | TABLE ACCESS FULL | SEG$ | 1 | 55 | | | | | | | |
  87.  
    | 48 | INDEX RANGE SCAN | I_USER2 | 1 | 1 | | | | | | | |
  88.  
    | 49 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | | | | | | | |
  89.  
    | 50 | INDEX UNIQUE SCAN | I_TS# | 1 | | | | | | | | |
  90.  
    | 51 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | | | | | | | |
  91.  
    | 52 | NESTED LOOPS | | 457 | 1806 | | | 1 | | | | |
  92.  
    | -> 53 | HASH JOIN | | 6853 | 1806 | 121 | +6 | 1 | 0 | 1M | | |
  93.  
    | -> 54 | VIEW | SYS_DBA_SEGS | 6853 | 1781 | 121 | +6 | 1 | 3363 | | | |
  94.  
    | -> 55 | UNION-ALL | | | | 121 | +6 | 1 | 3363 | | | |
  95.  
    | 56 | NESTED LOOPS | | 1 | 22 | 1 | +6 | 1 | 18 | | | |
  96.  
    | 57 | NESTED LOOPS OUTER | | 1 | 21 | 1 | +6 | 1 | 18 | | | |
  97.  
    | 58 | NESTED LOOPS | | 1 | 20 | 1 | +6 | 1 | 18 | | | |
  98.  
    | 59 | NESTED LOOPS | | 1 | 20 | 1 | +6 | 1 | 18 | | | |
  99.  
    | 60 | TABLE ACCESS FULL | UNDO$ | 18 | 2 | 1 | +6 | 1 | 18 | | | |
  100.  
    | 61 | TABLE ACCESS CLUSTER | SEG$ | 1 | 1 | 1 | +6 | 18 | 18 | | | |
  101.  
    | 62 | INDEX UNIQUE SCAN | I_FILE#_BLOCK# | 1 | | 1 | +6 | 18 | 18 | | | |
  102.  
    | 63 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | 1 | +6 | 18 | 18 | | | |
  103.  
    | 64 | INDEX RANGE SCAN | I_USER2 | 1 | 1 | 1 | +6 | 18 | 18 | | | |
  104.  
    | 65 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | 1 | +6 | 18 | 18 | | | |
  105.  
    | 66 | INDEX UNIQUE SCAN | I_TS# | 1 | | 1 | +6 | 18 | 18 | | | |
  106.  
    | -> 67 | NESTED LOOPS | | 6852 | 1759 | 121 | +6 | 1 | 3345 | | | |
  107.  
    | -> 68 | VIEW | VW_JF_SET$7C596FAF | 6852 | 1758 | 121 | +6 | 1 | 3345 | | | |
  108.  
    | -> 69 | UNION-ALL | | | | 121 | +6 | 1 | 3345 | | | |
  109.  
    | -> 70 | HASH JOIN RIGHT OUTER | | 6851 | 1701 | 121 | +6 | 1 | 3345 | 2M | | |
  110.  
    | 71 | INDEX FULL SCAN | I_USER2 | 103 | 1 | 1 | +6 | 1 | 103 | | | |
  111.  
    | -> 72 | HASH JOIN | | 6851 | 1700 | 126 | +1 | 1 | 3345 | 2M | 70.40 | Cpu (88) |
  112.  
    | 73 | VIEW | SYS_OBJECTS | 10141 | 1581 | 1 | +6 | 1 | 10196 | | | |
  113.  
    | 74 | UNION-ALL | | | | 1 | +6 | 1 | 10196 | | | |
  114.  
    | 75 | TABLE ACCESS FULL | TAB$ | 3007 | 393 | 1 | +6 | 1 | 3007 | | | |
  115.  
    | 76 | TABLE ACCESS FULL | TABPART$ | 155 | 4 | 1 | +6 | 1 | 177 | | | |
  116.  
    | 77 | TABLE ACCESS FULL | CLU$ | 10 | 392 | 1 | +6 | 1 | 10 | | | |
  117.  
    | 78 | TABLE ACCESS FULL | IND$ | 5326 | 393 | 1 | +6 | 1 | 5328 | | | |
  118.  
    | 79 | TABLE ACCESS FULL | INDPART$ | 302 | 5 | 1 | +6 | 1 | 325 | | | |
  119.  
    | 80 | TABLE ACCESS FULL | LOB$ | 1307 | 389 | 1 | +6 | 1 | 1316 | | | |
  120.  
    | 81 | TABLE ACCESS FULL | TABSUBPART$ | 32 | 2 | 1 | +6 | 1 | 32 | | | |
  121.  
    | 82 | TABLE ACCESS FULL | INDSUBPART$ | 1 | 2 | | | 1 | | | | |
  122.  
    | 83 | TABLE ACCESS FULL | LOBFRAG$ | 1 | 2 | 1 | +6 | 1 | 1 | | | |
  123.  
    | -> 84 | MERGE JOIN CARTESIAN | | 50994 | 117 | 121 | +6 | 1 | 254M | | 18.40 | Cpu (23) |
  124.  
    | -> 85 | NESTED LOOPS | | 1 | 56 | 121 | +6 | 1 | 3360 | | | |
  125.  
    | -> 86 | TABLE ACCESS FULL | SEG$ | 1 | 55 | 121 | +6 | 1 | 3360 | | | |
  126.  
    | -> 87 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | 121 | +6 | 3360 | 3360 | | | |
  127.  
    | -> 88 | INDEX UNIQUE SCAN | I_TS# | 1 | | 121 | +6 | 3360 | 3360 | | | |
  128.  
    | -> 89 | BUFFER SORT | | 75479 | 116 | 125 | +2 | 3360 | 254M | 3M | 11.20 | Cpu (14) |
  129.  
    | 90 | INDEX FAST FULL SCAN | I_OBJ1 | 75479 | 61 | 1 | +6 | 1 | 75509 | | | |
  130.  
    | 91 | NESTED LOOPS | | 1 | 57 | | | | | | | |
  131.  
    | 92 | NESTED LOOPS OUTER | | 1 | 56 | | | | | | | |
  132.  
    | 93 | TABLE ACCESS FULL | SEG$ | 1 | 55 | | | | | | | |
  133.  
    | 94 | INDEX RANGE SCAN | I_USER2 | 1 | 1 | | | | | | | |
  134.  
    | 95 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | | | | | | | |
  135.  
    | 96 | INDEX UNIQUE SCAN | I_TS# | 1 | | | | | | | | |
  136.  
    | -> 97 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | 121 | +6 | 3345 | 3345 | | | |
  137.  
    | 98 | FIXED TABLE FULL | X$KTFBUE | 100K | 24 | | | | | | | |
  138.  
    | 99 | INDEX UNIQUE SCAN | I_FILE2 | 1 | | | | | | | | |
  139.  
    =================================================================================================================================================================
  140.  
     
  141.  
     
  142.  
    Elapsed: 00:00:00.16
  143.  
    SQL>

 

10,相关的查询语句

-----生成html格式 
set trimspool on
set trim on
set pages 0
set linesize 1000
set long 1000000
set longchunksize 1000000
spool 1.html
select dbms_sqltune.report_sql_monitor(sql_id=>'&sqlid',type=>'ACTIVE') from dual;
spool off


----生成text
SET LONG 1000000
SET LONGCHUNKSIZE 1000000
SET LINESIZE 1000
SET PAGESIZE 0
SELECT DBMS_SQLTUNE.report_sql_monitor(sql_id => '&sqlid', type => 'TEXT')  report FROM dual;