Thursday, May 24, 2012

Simply View Oracle Session Usage


Here are some of PL/SQL scripts related to gather session statistics that I have developed to monitor the session usage.If the database getting slow it is possible to analyze using this that the resource usage by user connected

 SELECT
  'Currently, '
  || (SELECT COUNT(*) FROM V$SESSION)
  || ' out of '
  || DECODE(VL.SESSIONS_MAX,0,'unlimited',VL.SESSIONS_MAX)
  || ' connections are used.' AS USAGE_MESSAGE
FROM
  V$LICENSE VL










 SELECT
  'Currently, '
  || (SELECT COUNT(*) FROM V$SESSION)
  || ' out of '
  || VP.VALUE
  || ' connections are used.' AS USAGE_MESSAGE
FROM
  V$PARAMETER VP
WHERE VP.NAME = 'sessions'


 SELECT SUBSTR (df.NAME, 1, 40) file_name, df.bytes / 1024 / 1024 allocated_mb,
       ((df.bytes / 1024 / 1024) - NVL (SUM (dfs.bytes) / 1024 / 1024, 0))
       used_mb,
       NVL (SUM (dfs.bytes) / 1024 / 1024, 0) free_space_mb
       FROM v$datafile df,dba_free_space dfs
       WHERE df.file# = dfs.file_id(+)
       GROUP BY dfs.file_id, df.NAME, df.file#, df.bytes
       ORDER BY file_name;









No comments:

Post a Comment