View SQL statements with top 5 wait events

Source: Internet
Author: User

The dynamic performance view of the design is: V$session_event,v$session,v$sqlarea, the event can be found first in v$session_event, and then the SID is found through its dynamic performance view, which can be v$ Find the corresponding sql_id in the session, and then find the Sql_text in V$sqlarea by sql_id

View all the SQL statements for the event

SELECT DISTINCT S.sql_id,s.sid,se.event,se. Total_waits,sa.sql_text
From V$session s left join V$session_event se
On S.sid=se.sid
Left JOIN V$sqlarea SA
On s.sql_id=sa.sql_id
The Where SA. Sql_text is not NULL
ORDER BY se.total_waits Desc;

Query for the statement of a separate event event

Select S.sql_id,se.event,sa.sql_text
From V$session S, v$session_event se,v$sqlarea SA
where S.sid=se.sid and s.sql_id=sa.sql_id
and se.event=&event;

Sql> Select S.sql_id,se.event,sa.sql_text
From V$session S, v$session_event se,v$sqlarea SA
where S.sid=se.sid and s.sql_id=sa.sql_id
and se.event=&event; 2 3 4
Enter value for event: ' DB file sequential read '
Old 4:and Se.event=&event
New 4:and se.event= ' db file sequential read '

sql_id EVENT
------------- ----------------------------------------------------------------
Sql_text
--------------------------------------------------------------------------------
65VUZHM491WK9 db file Sequential read
DECLARE reason_id Dbms_server_alert.   reason_id_t: = NULL; Resour
CE_ID number; Db_name Recent_resource_incarnations$.db_unique_name%ty
PE: =:d b_unique_name; Inst_name Recent_resource_incar
Nations$.instance_name%type: =: instance_name; event_id
Number: =: event_id; Event_time TIMESTAMP with time ZONE: =
To_timestamp_tz (: Event_time, ' YYY
Y-mm-dd HH24:MI:SS. FF tzh:tzm ', ' nls_calendar=
' Gregorian '); BEGIN case:reason_name when ' database_up ' then

sql_id EVENT
------------- ----------------------------------------------------------------
Sql_text
--------------------------------------------------------------------------------
reason_id: = Dbms_server_alert.     RSN_FAN_DATABASE_UP; When ' Databa
Se_down ' then reason_id: = Dbms_server_alert. Rsn_fan_database_down;
When the ' instance_up ' then reason_id: = Dbms_server_alert. Rsn_fan_ins
TANCE_UP; When ' Instance_down ' then reason_id: = Dbms_server_al
Ert.   Rsn_fan_instance_down; When '

View SQL statements with top 5 wait events

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.