Monday, June 04, 2007

[Oracle 10G] GV$ACTIVE_SESSION_HISTORY; sample for query check Most waiting

I opened website, I found V$ACTIVE_SESSION_HISTORY; What is that?


V$ACTIVE_SESSION_HISTORY displays sampled session activity in the database. It contains snapshots of active database sessions taken once a second. A database session is considered active if it was on the CPU or was waiting for an event that didn't belong to the Idle wait class. Refer to the V$EVENT_NAME view for more information on wait classes.


How can I check most active Concurrency.

Example

SQL> SELECT DISTINCT wait_class FROM gv$event_name;
WAIT_CLASS
----------------------------------------------------------------
Concurrency
System I/O
User I/O
Administrative
Other
Configuration
Scheduler
Cluster
Application
Idle
Network
Commit


SQL> SELECT sql_id, COUNT(*)
FROM gv$active_session_history ash, gv$event_name evt
WHERE ash.sample_time > SYSDATE - 1/24
AND ash.session_state = 'WAITING'
AND ash.event_id = evt.event_id
AND evt.wait_class = 'Concurrency'
GROUP BY sql_id
ORDER BY COUNT(*) DESC;


Perhaps You can change Concurrency to anything.

SQL> SELECT sql_id, COUNT(*)
FROM gv$active_session_history ash, gv$event_name evt
WHERE ash.sample_time > SYSDATE - 1/24
AND ash.session_state = 'WAITING'
AND ash.event_id = evt.event_id
AND evt.wait_class = 'User I/O'
GROUP BY sql_id
ORDER BY COUNT(*) DESC;

No comments: