Script: View historical SQL Execution Information

Source: Internet
Author: User

Script: View historical SQL Execution Information SELECT * FROM (SELECT '1. v $ SQL '| 'instance No.:' | GV $ SQL. inst_id source, SQL _ID, plan_hash_value, TO_CHAR (FIRST_LOAD_TIME) begin_time, '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 = '9mq90p42frzgz '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 = '9mq90p42frzgz '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 = '9mq90p42frzgz 'UNION ALL SELECT DISTINCT' 4. dba_hist_sqlstat '| 'instance number:' | 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 .exe cutions_delta, SQL. buffer_gets_delta/DECODE (NVL (SQL .exe cutions_delta, 0), 0, 1, SQL .exe cutions_delta) "LIO/exec", (SQL. cpu_time_delta/1000000)/DECODE (NVL (SQL .exe cutions_delta, 0), 0, 1, SQL .exe cutions_delta) "CPUTIM/exec", (SQL. elapsed_time_delta/1000000)/DECODE (NVL (SQL .exe cutions_delta, 0), 0, 1, SQL .exe cutions_delta) "ETIME/exec", SQL. DISK_READS_DELTA/DECODE (NVL (SQL .exe cutions_delta, 0), 0, 1, SQL .exe cutions_delta) "PIO/exec", SQL. ROWS_PROCESSED_DELTA/DECODE (NVL (SQL .exe cutions_delta, 0), 0, 1, SQL .exe cutions_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 ('9mq90p42frzgz ') ORDER BY source, begin_time DESC;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.