Two easy-to-use SQL statements to quickly identify possible causes of a problem when database resource consumption is high

Source: Internet
Author: User

1. View the SQL statement being executed

(1) SQL statement:

Select distinct s.sid,s.sql_id,s.event,s.program, S.machine, Q.sql_text from v$session s,v$sql q

where s.sql_id=q.sql_id and S.status=' ACTIVE 'orderby Sql_text;

(2) Description of Use:

When the database server is under high load, most of the resources may be consumed by running SQL, and querying to the executing SQL statement is the first step in opening a high-consumption reason box. This statement focuses on the SQL statements being executed, waiting events, initiators, initiating hosts and SQL code, and sorting by SQL text, when the database server load is high, you can use this statement to find out what statement the system is running when the current resource consumption is high, by sorting and displaying sql_id by text. Wait for an event to determine the SQL statement that caused the problem from a certain program

2. View the SQL statements that execute the most concurrency

(1) SQL statement:

Select sql_id,count(*) from v$sessiongroup by sql_id Order by 2 desc

(2) Description of Use:

When resource consumption is high, there must be a certain number of SQL statements running at the same time, but the possibility of a statement serial execution of a serious performance problem can occur on a low-configuration system, but the high-configuration server will not have a large impact, but the same problematic SQL statement high concurrency execution, High-configuration machines can also be dragged down, consistently high concurrency, can also indicate that the SQL statement may run slowly, the resource consumption is high, so, by looking at what is running the most of the statement, the cause of the problem is objectively judged SQL statement.

This article Li Junjie (Network Name: casing), engaged in "system architecture, operating systems, storage devices, databases, middleware, applications" six levels of systematic performance optimization work

Welcome to the System performance Optimization Professional group, to discuss performance optimization technology together. Group number: 258187244

Two easy-to-use SQL statements to quickly identify possible causes of a problem when database resource consumption is high

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.