SELECT * FROM (SELECT '1.v$sql'||'实例号:'||GV$SQL.inst_id source, SQL_ID, plan_hash_value, TO_CHAR (FIRST_LOAD_TIME) begin_time, '在cursor cache中' end_time, executions "No. of exec", (buffer_gets / executions) "LIO/exec", (cpu_time / executions / 1000000) "CPUTIM/exec", (elapsed_time / executions / 1000000) "ETIME/exec", (disk_reads / executions) "PIO/exec", (ROWS_PROCESSED / executions) "ROWs/exec" FROM Gv$SQL WHERE sql_id = '&A' UNION ALL SELECT '2.sqltuning set' source, sql_id, plan_hash_value, 'JUST SQLSET NO DATE' begin_time, 'JUST SQLSET NO DATE' end_time, EXECUTIONS "No. of exec", (buffer_gets / executions) "LIO/exec", (cpu_time / executions / 1000000) "CPUTIM/exec", (elapsed_time / executions / 1000000) "ETIME/exec", (disk_reads / executions) "PIO/exec", (ROWS_PROCESSED / executions) "ROWs/exec" FROM dba_sqlset_statements WHERE SQL_ID = '&A' UNION ALL SELECT '3.dba_advisor_sqlstats' source, sql_id, plan_hash_value, 'JUST SQLSET NO DATE' begin_time, 'JUST SQLSET NO DATE' end_time, EXECUTIONS "No. of exec", (buffer_gets / executions) "LIO/exec", (cpu_time / executions / 1000000) "CPUTIM/exec", (elapsed_time / executions / 1000000) "ETIME/exec", (disk_reads / executions) "PIO/exec", (ROWS_PROCESSED / executions) "ROWs/exec" FROM dba_sqlset_statements WHERE SQL_ID = '&A' UNION ALL SELECT DISTINCT '4.dba_hist_sqlstat' || '实例号:' || SQL.INSTANCE_NUMBER source, sql_id, PLAN_HASH_VALUE, TO_CHAR (s.BEGIN_INTERVAL_TIME ,'YYYY-MM-DD hh24:mi:ss') begin_time, TO_CHAR (s.END_INTERVAL_TIME,'YYYY-MM-DD hh24:mi:ss') end_time, SQL.executions_delta, SQL.buffer_gets_delta / DECODE (NVL (SQL.executions_delta, 0), 0, 1, SQL.executions_delta) "LIO/exec", (SQL.cpu_time_delta / 1000000) / DECODE (NVL (SQL.executions_delta, 0), 0, 1, SQL.executions_delta) "CPUTIM/exec", (SQL.elapsed_time_delta / 1000000) / DECODE (NVL (SQL.executions_delta, 0), 0, 1, SQL.executions_delta) "ETIME/exec", SQL.DISK_READS_DELTA / DECODE (NVL (SQL.executions_delta, 0), 0, 1, SQL.executions_delta) "PIO/exec", SQL.ROWS_PROCESSED_DELTA / DECODE (NVL (SQL.executions_delta, 0), 0, 1, SQL.executions_delta) "ROWs/exec" FROM dba_hist_sqlstat SQL, dba_hist_snapshot s WHERE SQL.INSTANCE_NUMBER = s.INSTANCE_NUMBER AND SQL.dbid = (SELECT dbid FROM v$database) AND s.snap_id = SQL.snap_id AND sql_id IN ('&A')) ORDER BY source, begin_time DESC;
SQL ID HISTORY
Posted
in
by
Tags:
Leave a Reply