The document contains SQL queries to check various database performance metrics in Oracle including:
1. Active database sessions and their details.
2. Long running operations and their progress.
3. The number of log switches per hour.
4. Predicted I/O requirements for different buffer cache sizes.
5. The buffer cache hit ratio.
6. Usage details of the SGA components.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
55 views
Useful Scripts
The document contains SQL queries to check various database performance metrics in Oracle including:
1. Active database sessions and their details.
2. Long running operations and their progress.
3. The number of log switches per hour.
4. Predicted I/O requirements for different buffer cache sizes.
5. The buffer cache hit ratio.
6. Usage details of the SGA components.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
1.
Check active sessions
SQL> SET LINESIZE 500
SET PAGESIZE 1000
SQL> COLUMN username FORMAT A30
COLUMN osuser FORMAT A20 COLUMN spid FORMAT A10 COLUMN service_name FORMAT A15 COLUMN module FORMAT A45 COLUMN machine FORMAT A30 COLUMN logon_time FORMAT A20
SQL> SELECT NVL(s.username, '(oracle)') AS username,
s.osuser, s.sid, s.serial#, p.spid, s.lockwait, s.status, s.module, s.machine, s.program, TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time, s.last_call_et AS last_call_et_secs FROM v$session s, v$process p WHERE s.paddr = p.addr AND s.status = 'ACTIVE' ORDER BY s.username, s.osuser;
2. Check long operations
SQL> COLUMN sid FORMAT 999
COLUMN serial# FORMAT 9999999 COLUMN machine FORMAT A30 COLUMN progress_pct FORMAT 99999999.00 COLUMN elapsed FORMAT A10 COLUMN remaining FORMAT A10
SQL> SELECT s.sid,
s.serial#, s.machine, ROUND(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed, ROUND(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) remaining, ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct FROM v$session s, v$session_longops sl WHERE s.sid = sl.sid AND s.serial# = sl.serial#;
3.Check the number of log switch per hour
SQL> SET PAGESIZE 90
SET LINESIZE 150 SQL> set heading on column "00:00" format 9999 column "01:00" format 9999 column "02:00" format 9999 column "03:00" format 9999 column "04:00" format 9999 column "05:00" format 9999 column "06:00" format 9999 column "07:00" format 9999 column "08:00" format 9999 column "09:00" format 9999 column "10:00" format 9999 column "11:00" format 9999 column "12:00" format 9999 column "13:00" format 9999 column "14:00" format 9999 column "15:00" format 9999 column "16:00" format 9999 column "17:00" format 9999 column "18:00" format 9999 column "19:00" format 9999 column "20:00" format 9999 column "21:00" format 9999 column "22:00" format 9999 column "23:00" format 9999
estd_physical_reads FROM V$DB_CACHE_ADVICE WHERE name = 'DEFAULT' AND block_size = (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size') AND advice_status = 'ON';