Script to Find Most Active Session in Oracle Database for Last One Hour

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
These SQLs to identify most active sessions in the oracle database for last one hour. Two queries mentioned here for the background and foreground processes. 




SQL1. Foreground Process


SET PAGES 10000 LINES 222
COL SQL_ID FOR A15
col SQLTEXT for a60
SELECT sa.sql_id,sa.sql_text SQLTeXT,COUNT(*),ROUND(COUNT(*)/SUM(COUNT(*)) OVER(), 2) PCTLOAD
FROM gv$active_session_history hist, Gv$sqlarea sa
WHERE sample_time > SYSDATE - 1/24
AND session_type = 'FOREGROUND'
AND sa.sql_id=hist.sql_id
GROUP BY sa.sql_id,sa.sql_text
ORDER BY COUNT(*) DESC;

SQL_ID  SQLTEXT              COUNT(*)    PCTLOAD
--------------- ------------------------------------------------------------ ---------- ----------
1rw87c99mu66n SELECT sql_id,COUNT(*),ROUND(COUNT(*)/SUM(COUNT(*)) OVER(),       1   1
  2) PCTLOAD FROM gv$active_session_history WHERE sample_time
  > SYSDATE - 1/24 AND session_type = 'BACKGROUND' GROUP BY sq
  l_id ORDER BY COUNT(*) DESC

advertisements
 
SQL2. Background Process

SET PAGES 10000 LINES 222
COL SQL_ID FOR A15
col SQLTEXT for a60
SELECT sa.sql_id,sa.sql_text SQLTeXT,COUNT(*),ROUND(COUNT(*)/SUM(COUNT(*)) OVER(), 2) PCTLOAD
FROM gv$active_session_history hist, Gv$sqlarea sa
WHERE sample_time > SYSDATE - 1/24
AND session_type = 'BACKGROUND'
AND sa.sql_id=hist.sql_id
GROUP BY sa.sql_id,sa.sql_text
ORDER BY COUNT(*) DESC;
SQL_ID  SQLTEXT              COUNT(*)    PCTLOAD
--------------- ------------------------------------------------------------ ---------- ----------
5yv7yvjgjxugg select TIME_WAITED_MICRO from V$SYSTEM_EVENT  where event =       1        .25
  'Shared IO Pool Memory'

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer