Oracle queries perform slow SQL every day

Source: Internet
Author: User

This article is reproduced from http://blog.itpub.net/28602568/viewspace-1364844/

Preface:  Do you want to query, summarize or optimize the rows of SQL every day, the following SQL wants to help    ---query perform slow sql:select s.sql_text every day,        s.sql_fulltext,       s.sql_id,        round (Elapsed_time/ 1000000 /(case                WHEN  (Executions = 0 or nvl ( executions, 1 ) = 1)  THEN                 1                ELSE                Executions             end),              2) "Execution time ' S '",        S.executions "executionTimes ",       s.optimizer_cost" cost ",       S.SORTS,        s.module, --Connection mode (JDBC THIN CLIENT: Program)         --s.locked_total,       s.physical_read_bytes "Physical reading",        --s.physical_read_requests "Physical read request",       S.PHYSICAL_WRITE _requests "Physical Write",        --s.physical_write_bytes "Physical Write Request",        s.rows_processed      "return rows",       S. disk_reads          "Disk read",       S. direct_writes       "Direct Path write",       S.PARSING_SCHEMA_ name,       S.last_active_time  from gv$sqlarea S WHERE ROUND (Elapsed_time/ 1000000 /(case                WHEN  (executions = 0 or nvl (executions, 1 ) = 1)  then                1                ELSE                 executions              end),              2) > 5 --100 0000 μs =1s   and s.parsing_ Schema_name = user   and to_char (s.last_load_time,  ' YYYY-MM-DD ') =        to_char ( SYSDATE,  ' yyyy-mm-dd '  )    and s.command_ type in  (2 ,&Nbsp;3, 5, 6 , 189)  ORDER BY  "Execution Time '"  DESC; 
/* Command_type meaning in sql:
2:insert3:select6:update7:delete189:merge
Details can be found V$sqlcommand view */V$sqlarea official website Explanation: http://docs.oracle.com/cd/E11882_01/server.112/e40402/dynviews_3064.htm# REFRN30259 V$sqlcommand Official website explanation: http://docs.oracle.com/cd/E11882_01/server.112/e40402/dynviews_3066.htm#REFRN30632

Oracle queries perform slow SQL every day

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.