Sunday 29 November 2020

LOG MINER : Log miner_current_scn


LOGMINER - Based on SCN 

Scenario Preview:

We have archive log of particular date, with the help of  logminer we can extract the value based on SCN Number.

In general we can extract object value based on archive log | Timestamp date |  SCN Number

Operating System: OEL 7.7 64 bit

Database Version : 12.2.0.1 

Database : SMRUPGR12QA

Schema : infodba

Log Miner table : PFND0GENERALAUDIT

  • Check UTL_FILE_DIR location below.

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string

  • We need to take bounce of  database as parameter value is not set as dyanamics to set UTL_FILE_DIR  location.

SQL> alter system set utl_file_dir='/u04/db_backup/expdp/SMRUPGR12QA/logminer' scope=spfile;

System altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 2147483648 bytes

Fixed Size                  3712904 bytes

Variable Size             822085752 bytes

Database Buffers         1308622848 bytes

Redo Buffers               13062144 bytes

Database mounted.

Database opened.

SQL> @d

NAME                             INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN

-------------------------------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------

SMRUPGR1                         SMRUPGR12QA      SMRUPGR12QA                    READ WRITE           PRIMARY          NO                 0

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string      /u04/db_backup/expdp/SMRUPGR12

                                                 QA/logminer

  • Create directory for storing logminer file location 

SQL> CREATE OR REPLACE DIRECTORY LOG_DIR AS '/u04/db_backup/expdp/SMRUPGR12QA/logminer';

Directory created.

  • Optional if we wants to exract from particular users

SQL> GRANT READ, WRITE ON DIRECTORY LOG_DIR TO infodba;

Grant succeeded.

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME

--------

NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Database altered.

  • Start log miner specifying name and location 

 SQL>  BEGIN

sys.DBMS_LOGMNR_D.build (

dictionary_filename => 'date_lgmnrdict.ora',

dictionary_location => 'LOG_DIR');

END;

/  2    3    4    5    6

PL/SQL procedure successfully completed.

  • Using mention and specify the  archive log values below. 

SQL> BEGIN

DBMS_LOGMNR.add_logfile (

  2    3  options => DBMS_LOGMNR.new,

logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_737_hvcwzj71_.arc');

  4    5

  6  DBMS_LOGMNR.add_logfile (

  7  options => DBMS_LOGMNR.addfile,

  8  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_738_hvd82hth_.arc');

  9

 10  DBMS_LOGMNR.add_logfile (

 11  options => DBMS_LOGMNR.addfile,

 12  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_739_hvfq7xpq_.arc');

 13

 14  END;

 15  /

PL/SQL procedure successfully completed. 

SQL>  BEGIN

sys.DBMS_LOGMNR_D.build (

dictionary_filename => 'date_lgmnrdict.ora',

dictionary_location => 'LOG_DIR');

END;

/  2    3    4    5    6

PL/SQL procedure successfully completed.

  • Using mention and specify the archive log values below. 

SQL> BEGIN

DBMS_LOGMNR.add_logfile (

  2    3  options => DBMS_LOGMNR.new,

logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_737_hvcwzj71_.arc');

  4    5

  6  DBMS_LOGMNR.add_logfile (

  7  options => DBMS_LOGMNR.addfile,

  8  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_738_hvd82hth_.arc');

  9

 10  DBMS_LOGMNR.add_logfile (

 11  options => DBMS_LOGMNR.addfile,

 12  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_739_hvfq7xpq_.arc');

 13

 14  END;

 15  /


PL/SQL procedure successfully completed.

  • Log miner Based on SCN Number

begin

DBMS_LOGMNR.start_logmnr (

dictfilename => '/oradb/logminer/lgmnrdict.ora',

startscn => 20734338,

endscn => 20834345);

END;

PL/SQL procedure successfully completed.

SQL>

SELECT seg_owner, seg_name, count(*) AS Hits
FROM   v$logmnr_contents
WHERE  seg_name NOT LIKE '%$'
GROUP BY seg_owner, seg_name;


SELECT OPERATION, STATUS, SQL_REDO FROM V$LOGMNR_CONTENTS WHERE SEG_OWNER = 'INFODBA' AND TABLE_NAME = 'PFND0GENERALAUDIT';


SQL> EXECUTE DBMS_LOGMNR.END_LOGMNR();

PL/SQL procedure successfully completed.

SQL>
 

Log Miner : Date_Timestamp_logminer


LOGMINER - Based on Date and time generation

Scenario Preview:

We have archive log of particular date, with the help of  logminer we can extract the value based on date and time.

In general we can extract object value based on archive log | Timestamp date |  SCN Number

Operating System: OEL 7.7 64 bit

Database Version : 12.2.0.1 

Database : SMRUPGR12QA

Schema : infodba

Log Miner table : PFND0GENERALAUDIT

Check UTL_FILE_DIR location below.

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string

  • We need to take bounce of  database as parameter value is not set as dyanamics to set UTL_FILE_DIR  location.

SQL> alter system set utl_file_dir='/u04/db_backup/expdp/SMRUPGR12QA/logminer' scope=spfile;

System altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 2147483648 bytes

Fixed Size                  3712904 bytes

Variable Size             822085752 bytes

Database Buffers         1308622848 bytes

Redo Buffers               13062144 bytes

Database mounted.

Database opened.

SQL> @d

NAME                             INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN

-------------------------------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------

SMRUPGR1                         SMRUPGR12QA      SMRUPGR12QA                    READ WRITE           PRIMARY          NO                 0

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string      /u04/db_backup/expdp/SMRUPGR12

                                                 QA/logminer

Create directory for storing logminer file location 

SQL> CREATE OR REPLACE DIRECTORY LOG_DIR AS '/u04/db_backup/expdp/SMRUPGR12QA/logminer';

Directory created.

Optional if we wants to exract from particular users

SQL> GRANT READ, WRITE ON DIRECTORY LOG_DIR TO infodba;

Grant succeeded.

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME

--------

NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;


Database altered.

  • Start log miner specifying name and location 

 SQL>  BEGIN

sys.DBMS_LOGMNR_D.build (

dictionary_filename => 'date_lgmnrdict.ora',

dictionary_location => 'LOG_DIR');

END;

/  2    3    4    5    6


PL/SQL procedure successfully completed.

  • Using mention and specify the  archive log values below. 

SQL> BEGIN

DBMS_LOGMNR.add_logfile (

  2    3  options => DBMS_LOGMNR.new,

logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_737_hvcwzj71_.arc');

  4    5

  6  DBMS_LOGMNR.add_logfile (

  7  options => DBMS_LOGMNR.addfile,

  8  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_738_hvd82hth_.arc');

  9

 10  DBMS_LOGMNR.add_logfile (

 11  options => DBMS_LOGMNR.addfile,

 12  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_739_hvfq7xpq_.arc');

 13

 14  END;

 15  /


PL/SQL procedure successfully completed.

  • Start log mining mentioning date and time

SQL> begin

dbms_logmnr.start_logmnr (

dictfilename => '/u04/db_backup/expdp/SMRUPGR12QA/logminer/date_lgmnrdict.ora',

  2    3    4  starttime => TO_DATE('19-NOV-2020 05:26:00', 'DD-MON-YYYY HH:MI:SS'),

  5  endtime => TO_DATE('19-NOV-2020 08:35:00', 'DD-MON-YYYY HH:MI:SS'));

end;

/  6    7


PL/SQL procedure successfully completed.

  • Example to check the logs contents 

SQL>

SELECT seg_owner, seg_name, count(*) AS Hits
FROM   v$logmnr_contents
WHERE  seg_name NOT LIKE '%$'
GROUP BY seg_owner, seg_name;


SELECT OPERATION, STATUS, SQL_REDO FROM V$LOGMNR_CONTENTS WHERE SEG_OWNER = 'INFODBA' AND TABLE_NAME = 'PFND0GENERALAUDIT';

  • End log mining operations
SQL> EXECUTE DBMS_LOGMNR.END_LOGMNR();

PL/SQL procedure successfully completed.

SQL>

NEW LOGMINER - Based on archivelog generation

Scenario Preview:

We have archive log of particular date, with the help of  logminer we can extract the value based on archive log .

In general we can extract object value based on archive log | Timestamp date |  SCN Number

Operating System: OEL 7.7 64 bit

Database Version : 12.2.0.1 

Database : SMRUPGR12QA

Schema : infodba

Log Miner table : PFND0GENERALAUDIT

SQL> @d

NAME                             INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN

-------------------------------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------

SMRUPGR1                         SMRUPGR12QA      SMRUPGR12QA                    READ WRITE           PRIMARY          NO                 0


Check UTL_FILE_DIR location below.

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string

  • We need to take bounce of  database as parameter value is not set as dyanamics to set UTL_FILE_DIR  location.

SQL> alter system set utl_file_dir='/u04/db_backup/expdp/SMRUPGR12QA/logminer' scope=spfile;

System altered.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 2147483648 bytes

Fixed Size                  3712904 bytes

Variable Size             822085752 bytes

Database Buffers         1308622848 bytes

Redo Buffers               13062144 bytes

Database mounted.

Database opened.

SQL> @d

NAME                             INSTANCE_NAME    DB_UNIQUE_NAME                 OPEN_MODE            DATABASE_ROLE    CURRENT_SCN        FAILOVER_SCN

-------------------------------- ---------------- ------------------------------ -------------------- ---------------- ------------------ ----------------------------------------

SMRUPGR1                         SMRUPGR12QA      SMRUPGR12QA                    READ WRITE           PRIMARY          NO                 0

SQL> sho parameter utl_file_dir

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

utl_file_dir                         string      /u04/db_backup/expdp/SMRUPGR12

                                                 QA/logminer

Create directory for storing logminer file location 

SQL> CREATE OR REPLACE DIRECTORY LOG_DIR AS '/u04/db_backup/expdp/SMRUPGR12QA/logminer';

Directory created.

Optional if we wants to exract from particular users

SQL> GRANT READ, WRITE ON DIRECTORY LOG_DIR TO infodba;

Grant succeeded.

SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;

SUPPLEME

--------

NO

SQL> ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;


Database altered.

  • Start log miner specifying name and location 

SQL> BEGIN

sys.DBMS_LOGMNR_D.build (

dictionary_filename => 'lgmnrdict.ora',

dictionary_location => 'LOG_DIR');

END;

/  2    3    4    5    6

PL/SQL procedure successfully completed.

SQL> SQL>

SQL> SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/SMRUPGR12QA/redo01.log
/u01/app/oracle/oradata/SMRUPGR12QA/redo02.log
/u01/app/oracle/oradata/SMRUPGR12QA/redo03.log
  • Using mention archive log  values to log. 
SQL> BEGIN
DBMS_LOGMNR.add_logfile (
options => DBMS_LOGMNR.new,
logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_737_hvcwzj71_.arc');

DBMS_LOGMNR.add_logfile (
  2    3    4    5    6    7  options => DBMS_LOGMNR.addfile,
logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_738_hvd82hth_.arc');

DBMS_LOGMNR.add_logfile (
  8    9   10   11  options => DBMS_LOGMNR.addfile,
 12  logfilename => '/u04/db_backup/Flash_recovery_area/SMRUPGR12QA/SMRUPGR12QA/archivelog/2020_11_19/o1_mf_1_739_hvfq7xpq_.arc');
 13
 14  END;
/  15

PL/SQL procedure successfully completed.

SQL> sho user
USER is "SYS"
SQL>
  • Start log mining location 
SQL> sho user
USER is "SYS"
SQL> BEGIN
-- Start using all logs
DBMS_LOGMNR.start_logmnr (
dictfilename => '/u04/db_backup/expdp/SMRUPGR12QA/logminer/lgmnrdict.ora');
END;
/   2    3    4    5    6

PL/SQL procedure successfully completed.

SQL>
  • Check the log mining contents.
SELECT seg_owner, seg_name, count(*) AS Hits
FROM   v$logmnr_contents
WHERE  seg_name NOT LIKE '%$'
GROUP BY seg_owner, seg_name;

  • Check Tablevalue operation information details

SELECT OPERATION, STATUS, SQL_REDO FROM V$LOGMNR_CONTENTS WHERE SEG_OWNER = 'INFODBA' AND TABLE_NAME = 'PFND0GENERALAUDIT';
  • End log miner execution

SQL> EXECUTE DBMS_LOGMNR.END_LOGMNR();

PL/SQL procedure successfully completed.

SQL>

Wednesday 25 November 2020

PT - Row level lock contention TX blockers and waiters

 Handling 'enq: TX - row lock contention'

  • Client session 1 :  Recording current time and update customers row

SQL> SELECT TO_CHAR(SYSDATE, 'MM/DD/YY HH24:MI:SS') ctime FROM DUAL;


CTIME

-----------------

11/24/20 20:41:27


SQL> var V_CUSTOMER_ID number

SQL> exec :V_CUSTOMER_ID := 100


PL/SQL procedure successfully completed.


SQL> UPDATE CUSTOMERS

  2  SET CUST_EMAIL = CUST_EMAIL || '' WHERE CUSTOMER_ID = :V_CUSTOMER_ID;


1 row updated.

  • client Session 2 :  Same update statement run on session.


SQL> UPDATE CUSTOMERS SET CUST_EMAIL = CUST_EMAIL || '' WHERE CUSTOMER_ID =100;

output 
C:\Users\varunyadav>sqlplus sys/system123@orcl2 as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Nov 24 20:46:49 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

  • Query to check waiter and blocker session 

SQL> col SESSIONS format A20
SQL> SELECT DECODE(REQUEST,0,'Holder SID: ','Waiter SID: ') ||
  2  SID SESSIONS, ID1, ID2, LMODE, REQUEST, TYPE
  3  FROM V$LOCK
  4  WHERE (ID1, ID2, TYPE) IN (SELECT ID1, ID2, TYPE FROM V$LOCK WHERE REQUEST > 0)
  5  ORDER BY ID1, REQUEST;

SESSIONS                    ID1        ID2      LMODE    REQUEST TY
-------------------- ---------- ---------- ---------- ---------- --
Holder SID: 126          131085       1379          6          0 TX
Waiter SID: 867          131085       1379          0          6 TX

  • Information about waiter sessions details
SQL> set pagesize 20
SQL> col INFO for a200
SQL> SELECT
  2  'SID: '|| S.SID || CHR(10) ||
  3  'USERNAME: '|| S.USERNAME || CHR(10) ||
  4  'EVENT: ' || S.EVENT || CHR(10) ||
  5  'DESCRIPTION: ' || T.DESCRIPTION || CHR(10) ||
  6  'CURRENT STATEMENT: ' || Q.SQL_TEXT || CHR(10) ||
  7  'WAITING TIME (s): ' || S.SECONDS_IN_WAIT || CHR(10) ||
  8  'P1TEXT: ' || S.P1TEXT || CHR(10) ||
  9  'P1: ' || S.P1 || CHR(10) ||
 10  'P2TEXT: ' || S.P2TEXT || CHR(10) ||
 11  'P2: ' || S.P2 || CHR(10) ||
 12  'P3TEXT: ' || S.P3TEXT || CHR(10) ||
 13  'P3: ' || S.P3
 14  AS INFO
 15  FROM V$SESSION S, V$LOCK L, V$LOCK_TYPE T, V$SQL Q
 16  WHERE S.SID = L.SID AND T.TYPE=L.TYPE AND S.SQL_ID = Q.SQL_ID
 17  AND L.REQUEST>0;

INFO
--------------------------------------------------------------------------------
SID: 867
USERNAME: SOE
EVENT: enq: TX - row lock contention
DESCRIPTION: Lock held by a transaction to allow other transactions to wait for
it
CURRENT STATEMENT: UPDATE CUSTOMERS SET CUST_EMAIL = CUST_EMAIL || '' WHERE CUST
OMER_ID =100
WAITING TIME (s): 291
P1TEXT: name|mode
P1: 1415053318
P2TEXT: usn<<16 | slot
P2: 131085
P3TEXT: sequence
P3: 1379
  • Query to retrieve particular affected lock row

SQL> SELECT 'SELECT * FROM "' || O.OWNER || '"."' || O.OBJECT_NAME || '"
  2  WHERE ROWID = DBMS_ROWID.ROWID_CREATE(1, ' || S.ROW_WAIT_OBJ# || ', ' ||
  3  S.ROW_WAIT_FILE# || ', ' || ROW_WAIT_BLOCK# || ', ' ||
  4  ROW_WAIT_ROW# || ');'
  5  FROM DBA_OBJECTS O, V$SESSION S
  6  WHERE S.ROW_WAIT_OBJ# = O.OBJECT_ID AND S.SID = &V_WSID;
Enter value for v_wsid: 867
old   6: WHERE S.ROW_WAIT_OBJ# = O.OBJECT_ID AND S.SID = &V_WSID
new   6: WHERE S.ROW_WAIT_OBJ# = O.OBJECT_ID AND S.SID = 867

'SELECT*FROM"'||O.OWNER||'"."'||O.OBJECT_NAME||'"WHEREROWID=DBMS_ROWID.ROWID_CRE
--------------------------------------------------------------------------------
SELECT * FROM "SOE"."CUSTOMERS"
WHERE ROWID = DBMS_ROWID.ROWID_CREATE(1, 170508, 8, 4816, 38);


  • Rollback client session 1:

SQL>rollback;



SQL> SELECT DECODE(REQUEST,0,'Holder SID: ','Waiter SID: ') ||
  2  SID SESSIONS, ID1, ID2, LMODE, REQUEST, TYPE
  3  FROM V$LOCK
  4  WHERE (ID1, ID2, TYPE) IN (SELECT ID1, ID2, TYPE FROM V$LOCK WHERE REQUEST > 0)
  5  ORDER BY ID1, REQUEST;

no rows selected

SQL>

  • ASH report of particular locking periods: 


define dbid = '';
define inst_num = '';
define report_type = 'html';
define begin time
define begin_time ='-10'
define duration = 10;
define report_name = 'C:\Users\varunyadav\ash_enqtx.html';
define slot_width = '';
define target_session_id = '';
define target_sql_id = '';
define target_wait_class = '';
define target_service_hash = '';
define target_module_name = '';
define target_action_name = '';
define target_client_id = '';
define target_plsql_entry = '';
define target_container = '';
@?\rdbms\admin\ashrpti.sql


  • Query for enqueue wait events since last database start
SQL> col EVENT format a40
SQL> col WAIT_CLASS format a11
SQL> SELECT EVENT, AVERAGE_WAIT,
  2  TO_CHAR(ROUND(TIME_WAITED/100),'999,999,999') TIME_SECONDS, WAIT_CLASS
  3  FROM V$SYSTEM_EVENT
  4  WHERE EVENT LIKE 'enq%'
  5  ORDER BY TIME_WAITED;

EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS
---------------------------------------- ------------ ------------ -----------
enq: SQ - contention                              .14            0 Configurati
                                                                   on

enq: PV - syncstart                              1.35            0 Other
enq: CF - contention                             5.34            0 Other
enq: WF - contention                            20.17            0 Other
enq: CR - block range reuse ckpt                  .21            1 Other
enq: RO - fast object reuse                       .29            3 Application
enq: PR - contention                            18.46            6 Other
enq: JG - queue lock                             5.76           12 Other
enq: TX - row lock contention               233833.06        7,015 Application

9 rows selected.

SQL>
  • Query to check object waited for lock to be released

SQL> col OBJECT_NAME for a10
SQL> col stats for a20
SQL> SELECT OBJECT_NAME, SUBSTR(STATISTIC_NAME, 1, 30) STATS, VALUE
  2  FROM V$SEGMENT_STATISTICS
  3  WHERE ( STATISTIC_NAME IN( 'ITL waits' , 'row lock waits' ))
  4  AND VALUE>0 AND OBJECT_NAME NOT LIKE 'BIN$%'
  5  ORDER BY VALUE DESC;

OBJECT_NAM STATS                     VALUE
---------- -------------------- ----------
EMP        row lock waits                2
CUSTOMERS  row lock waits                1

SQL>
  • Query for most waited wait events of application class
SQL> col SQL_TEXT for a30
SQL> SELECT ROUND(APPLICATION_WAIT_TIME / 1000000) WAIT_TIME_S,
  2  SQL_ID, SUBSTR(SQL_TEXT,1,30) SQL_TEXT
  3  FROM V$SQLSTATS
  4  WHERE APPLICATION_WAIT_TIME >0
  5  ORDER BY APPLICATION_WAIT_TIME DESC FETCH FIRST 10 ROW ONLY;

WAIT_TIME_S SQL_ID        SQL_TEXT
----------- ------------- ------------------------------
       5372 9b21yxhcn6r9d UPDATE EMP SET SALARY=SALARY W
        948 fwwngr2fq76ap  UPDATE EMP SET SALARY=SALARY
        695 1d0m79rpx5h4j UPDATE CUSTOMERS SET CUST_EMAI
          2 6mcpb06rctk0x call dbms_space.auto_space_adv
          1 b6usrg82hwsa3 call dbms_stats.gather_databas

SQL>

Use Case: Using Session Waiting Events with Hung or Very Slow Sessions

Use Case: Using Session Waiting Events with Hung or Very Slow Sessions 

Scenario Overview:

we have 2 client session 1 &2 . We will update same row on table in both session and do not commit after session 1execution . and try to update same query on session 2 .

Checking the sessions details of waiter and blocker of session.

 SESSION 1

C:\Users\varunyadav>sqlplus soe/soe@orcl2

SQL*Plus: Release 12.2.0.1.0 Production on Tue Nov 24 16:30:41 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Nov 24 2020 16:30:13 +05:30

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>  UPDATE EMP SET SALARY=SALARY WHERE EMP_NO=104;

1 row updated.

SQL>

 SESSION 2

C:\Users\varunyadav>sqlplus soe/soe@orcl2

SQL*Plus: Release 12.2.0.1.0 Production on Tue Nov 24 16:30:41 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Nov 24 2020 16:30:13 +05:30

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>  UPDATE EMP SET SALARY=SALARY WHERE EMP_NO=104;

( Session above stuck as session 1 is not commit there update)

  • Checking the idle or hung  session details using query

C:\Users\varunyadav>sqlplus soe/soe@orcl2

SQL*Plus: Release 12.2.0.1.0 Production on Tue Nov 24 16:35:10 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Last Successful login time: Tue Nov 24 2020 16:30:41 +05:30

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> SELECT SID, EVENT
  2  FROM V$SESSION
  3  WHERE STATE='WAITING' AND USERNAME ='SOE' AND WAIT_CLASS<>'Idle';

       SID EVENT
---------- ----------------------------------------------------------------
       126 enq: TX - row lock contention

  • Hung session information 

SQL> col SESSION_WAITS format a100
SQL> SELECT 'SID: '|| SID||
  2  CHR(10)||'USERNAME: '|| USERNAME||
  3  CHR(10)||'STATE: '|| STATE||
  4  CHR(10)||'EVENT: '|| EVENT||
  5  CHR(10)||'WAIT_TIME: '|| WAIT_TIME||
  6  CHR(10)||'SECONDS_IN_WAIT: '|| SECONDS_IN_WAIT||
  7  CHR(10)||'WAIT_CLASS: '|| WAIT_CLASS||
  8  CHR(10)||'P1TEXT: '|| P1TEXT||
  9  CHR(10)||'P1: '|| P1||
 10  CHR(10)||'P2TEXT: '|| P2TEXT||
 11  CHR(10)||'P2: '|| P2 ||
 12  CHR(10)||'P3TEXT: '|| P3TEXT||
 13  CHR(10)||'P3: ' || P3 AS SESSION_WAITS
 14  FROM V$SESSION
 15  WHERE USERNAME='SOE' AND EVENT LIKE 'enq: TX%'
 16  ORDER BY WAIT_TIME;

SESSION_WAITS
--------------------------------------------------------------------------------
SID: 126
USERNAME: SOE
STATE: WAITING
EVENT: enq: TX - row lock contention
WAIT_TIME: 0
SECONDS_IN_WAIT: 280
WAIT_CLASS: Application
P1TEXT: name|mode
P1: 1415053318
P2TEXT: usn<<16 | slot
P2: 524304

SESSION_WAITS
--------------------------------------------------------------------------------
P3TEXT: sequence
P3: 1381


SQL> col EVENT for a30
SQL> SELECT E.EVENT,
  2  TO_CHAR(ROUND(E.TIME_WAITED/100),'999,999,999') TIME_SECONDS
  3  FROM V$SESSION_EVENT E, V$SESSION S
  4  WHERE E.SID=S.SID AND S.USERNAME='SOE' AND E.EVENT LIKE 'enq: TX%'
  5  ORDER BY TIME_WAITED;

EVENT                          TIME_SECONDS
------------------------------ ------------
enq: TX - row lock contention           307

  • Retrieve session history details

SQL> SELECT COUNT(*) FROM V$SESSION_WAIT_HISTORY
  2  WHERE EVENT LIKE 'enq: TX%';

  COUNT(*)
----------
         0

SQL>

<16 --------------------------------------------------------------------------------="" 1381="" 524304="" p2:="" p3:="" p3text:="" sequence="" session_waits="" slot="" sql="">ROLLBACK

<16 --------------------------------------------------------------------------------="" 1381="" 524304="" p2:="" p3:="" p3text:="" sequence="" session_waits="" slot="" sql="">Session 1
SQL> UPDATE EMP SET SALARY=SALARY WHERE EMP_NO=104; 
 1 row updated. 

 SQL> rollback; 
 Rollback complete. SQL>

<16 --------------------------------------------------------------------------------="" 1381="" 524304="" p2:="" p3:="" p3text:="" sequence="" session_waits="" slot="" sql="">Session 2
SQL> UPDATE EMP SET SALARY=SALARY WHERE EMP_NO=104; 
 1 row updated. 

 SQL> rollback; 
 Rollback complete. 

  • Wait event of sessions of schema
SQL>
SQL> col EVENT format a40
SQL> col WAIT_CLASS format a10
SQL> SELECT SID, EVENT, WAIT_CLASS
  2  FROM V$SESSION
  3  WHERE USERNAME='SOE';

       SID EVENT                                    WAIT_CLASS
---------- ---------------------------------------- ----------
        10 SQL*Net message to client                Network
       126 SQL*Net message from client              Idle
       867 SQL*Net message from client              Idle

SQL>


PT- Wait Class overview and query output examples


Wait Class

  • Application : eg - row level locking
  • Administration : eg Index rebuilding
  • Commit : eg - redo log confirmation after commit 
  • Concurrency - eg - buffer cache latch |lock contention
  • Configuration - Undersize cache
  • User I/O-  block read from disk for foreground process
  • Network Communications - transferring data| latency
  • Idle-  application foreground process connected but idle

Displaying Events statistics

  • V$system_event
  • V$session_event

  • V$service_event

  • V$system_wait_class

  • v$service_wait_class

  • v$session_wait_class

  • v$session

  • v$session_wait

  • v$session_wait_history

Common wait events

  • buffer busy waits : wait until buffer available
  • free buffer waits : wait until buffer gets free

  • db sequential reads: sequential reads from database

  • db scattered reads: read multiple blocks 

  • Enqueue : serial access from database

  • library cache: locked object in library cache

  • log buffer space : wait free space in log buffer cache
  • log file : wait for log file to finish


Query to check instance level statistics

SQL>col NAME format A50

col CLASS format A10

SELECT NAME,

DECODE(TO_CHAR(CLASS),

'1','User',

'2','Redo',

'4','Enqueue',

'8','Cache',

SQL&gt; SQL&gt;   2    3  '16','OS',  4

'32','RAC',

'33','RAC-User',

'40','RAC-Cache',

'64','SQL',

  5    6    7    8    9   10   11   12  '72','SQL-Cache',

'128','Debug',

 13   14  '192','Debug-SQL',

 15  TO_CHAR(CLASS)

) CLASS, VALUE

 16  FROM V$SYSSTAT

 17   18  ORDER BY CLASS,NAME;


NAME                                               CLASS           VALUE

-------------------------------------------------- ---------- ----------

redo non-durable records skipped                   34                  0

CR blocks created                                  Cache           30965

DBWR checkpoint buffers written                    Cache         1135880

DBWR checkpoints                                   Cache            1538

DBWR lru scans                                     Cache               0

DBWR object drop buffers written                   Cache            2797

DBWR parallel query checkpoint buffers written     Cache           11128

DBWR revisited being-written buffer                Cache               0

DBWR tablespace checkpoint buffers written         Cache             404

DBWR thread checkpoint buffers written             Cache               0

DBWR transaction table writes                      Cache           22774



query for stats of database Full table and index scans 

SQL> SELECT NAME, VALUE

FROM V$SYSSTAT

WHERE (NAME LIKE 'table%' or NAME LIKE 'index%') AND VALUE&lt;&gt;0

ORDER BY NAME;  2    3    4


NAME                                                    VALUE

-------------------------------------------------- ----------

index crx upgrade (positioned)                         116414

index fast full scans (full)                            37029

index fetch by key                                  118133973

index scans kdiixs1                                  43995778

table fetch by rowid                                416240355

table fetch continued row                              108874

table scan blocks gotten                             79206961

table scan disk non-IMC rows gotten                3957922038

table scan rows gotten                             4863040663

table scans (direct read)                               11789

table scans (long tables)                               13158


NAME                                                    VALUE

-------------------------------------------------- ----------

table scans (rowid ranges)                              11789

table scans (short tables)                            2327683


13 rows selected.

Top sessions of specific statistics:

SQL> SELECT S.SID, H.USERNAME, T.NAME, S.VALUE

FROM V$SESSTAT S, V$STATNAME T, V$SESSION H

WHERE S.STATISTIC# = T.STATISTIC# AND S.SID = H.SID

AND T.NAME = 'parse time cpu'

AND H.USERNAME IS NOT NULL

ORDER BY S.VALUE DESC;  2    3    4    5    6


       SID USERNAME   NAME                      VALUE

---------- ---------- -------------------- ----------

      1077 TCPRODMANA parse time cpu              496

           GER


      1082 TCPRODMANA parse time cpu              378

           GER


       777 TCPRODMANA parse time cpu               60

           GER


      1076 TCPRODMANA parse time cpu               60

           GER


       SID USERNAME   NAME                      VALUE

---------- ---------- -------------------- ----------


       626 TCPRODMANA parse time cpu               12

           GER


         3 INFODBA    parse time cpu                8

       164 INFODBA    parse time cpu                6

       774 SYS        parse time cpu                4

        10 INFODBA    parse time cpu                3

      1084 INFODBA    parse time cpu                2

       776 INFODBA    parse time cpu                2

      1083 INFODBA    parse time cpu                1

Statement text in the output:

SQL> col SQL_TEXT format a25

SQL> SELECT S.SID, H.USERNAME, T.NAME, S.VALUE, SUBSTR(Q.SQL_TEXT,1,25) SQL_TEXT

FROM V$SESSTAT S, V$STATNAME T, V$SESSION H, V$SQL Q

WHERE S.STATISTIC# = T.STATISTIC# AND S.SID = H.SID AND H.SQL_ID=Q.SQL_ID(+)

AND T.NAME = 'parse time cpu'

AND H.USERNAME IS NOT NULL

ORDER BY S.VALUE DESC;  2    3    4    5    6


       SID USERNAME   NAME                      VALUE SQL_TEXT

---------- ---------- -------------------- ---------- -------------------------

      1077 TCPRODMANA parse time cpu              496

           GER


      1082 TCPRODMANA parse time cpu              378

           GER


      1076 TCPRODMANA parse time cpu               60

           GER


       777 TCPRODMANA parse time cpu               60

           GER


       SID USERNAME   NAME                      VALUE SQL_TEXT

---------- ---------- -------------------- ---------- -------------------------


       626 TCPRODMANA parse time cpu               12

           GER


         3 INFODBA    parse time cpu                8

       164 INFODBA    parse time cpu                6

       774 SYS        parse time cpu                5 SELECT S.SID, H.USERNAME,

       774 SYS        parse time cpu                5 SELECT S.SID, H.USERNAME,

        10 INFODBA    parse time cpu                3

      1084 INFODBA    parse time cpu                2

       776 INFODBA    parse time cpu                2


SQL> SELECT S.SID, H.USERNAME, T.NAME, S.VALUE

FROM V$MYSTAT S, V$STATNAME T, V$SESSION H

WHERE S.STATISTIC# = T.STATISTIC# AND S.SID = H.SID

AND T.NAME = 'parse time cpu'

AND H.USERNAME IS NOT NULL

ORDER BY S.VALUE DESC;  2    3    4    5    6


       SID USERNAME   NAME                      VALUE

---------- ---------- -------------------- ----------

       774 SYS        parse time cpu                5


VIEWING WAIT EVENTS


SQL&gt; col EVENT format a40

col WAIT_CLASS format a11

SELECT EVENT, AVERAGE_WAIT,

TO_CHAR(ROUND(TIME_WAITED/100),'999,999,999') TIME_SECONDS, WAIT_CLASS

FROM V$SYSTEM_EVENT

WHERE TIME_WAITED&gt;0 AND WAIT_CLASS&lt;&gt;'Idle'

ORDER BY TIME_WAITED;SQL&gt; SQL&gt;   2    3    4    5


Display all the non-idle wait event statistics at the instance level.


SQL&gt; col EVENT format a40

col WAIT_CLASS format a11

SELECT EVENT, AVERAGE_WAIT,

TO_CHAR(ROUND(TIME_WAITED/100),'999,999,999') TIME_SECONDS, WAIT_CLASS

FROM V$SYSTEM_EVENT

WHERE TIME_WAITED&gt;0 AND WAIT_CLASS&lt;&gt;'Idle'

ORDER BY TIME_WAITED;SQL&gt; SQL&gt;   2    3    4    5


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

AQ Background Master: slave start                 .11            0 Other

get branch/thread/sequence enqueue                .01            0 Other

enq: SQ - contention                              .28            0 Configurati

                                                                   on


latch: gc element                                   0            0 Other

latch: cache buffers chains                         0            0 Concurrency

latch: shared pool                                  0            0 Concurrency

latch: active service list                          0            0 Other

enq: CT - state                                   .02            0 Other

enq: BR - file shrink                             .04            0 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

Sync ASM discovery                                .76            0 Other

ges LMON to get to FTDONE                         .34            0 Other

enq: FU - contention                              .05            0 Other

enq: AS - service activation                      .51            0 Other

enq: FL - Flashback database log                  .03            0 Other

gc cr block lost                                  .03            0 Cluster

enq: TT - contention                              .03            0 Other

enq: DW - contention                              .04            0 Other

enq: TX - allocate ITL entry                      .61            0 Configurati

                                                                   on



EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

IMR mount phase II completion                    3.01            0 Other

CSS group registration                            .15            0 Other

enq: TX - contention                              .21            0 Other

ges global resource directory to be froz            2            0 Other

en


latch: ges resource hash list                       0            0 Other

db file single write                              .05            0 User I/O

ASM: MARK subscribe to msg channel               4.23            0 Other

CGS skgxn join retry                             5.25            0 Other

enq: XL - fault extent map                        .77            0 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

LGWR wait for redo copy                             0            0 Other

ges DFS hang analysis phase 2 acks                .81            0 Other

enq: WT - contention                              .03            0 Other

GCR CSS group update                                0            0 Other

ADR file lock                                       0            0 Other

Parameter File I/O                                .09            0 User I/O

cursor: pin S                                     .11            0 Concurrency

GCR CSS group query                                 0            0 Other

recovery area: computing dropped files            .96            0 Other

gc current split                                  .11            0 Cluster

ges generic event                                2.04            0 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

log file single write                             .03            0 System I/O

asynch descriptor resize                            0            0 Other

enq: TK - Auto Task Serialization                 .03            0 Other

CSS group membership query                        .05            0 Other

recovery read                                     .15            0 System I/O

PX Deq: Table Q Get Keys                          .09            0 Other

enq: MW - contention                              .03            0 Other

enq: DR - contention                              .04            0 Other

latch: call allocation                            .01            0 Other

log file switch completion                       1.21            0 Configurati

                                                                   on


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------


enq: AF - task serialization                      .03            0 Other

enq: US - contention                              .03            0 Other

enq: JS - queue lock                              .25            0 Other

recovery area: computing backed up files          2.5            0 Other

enq: TQ - DDL contention                         5.66            0 Other

enq: RS - prevent file delete                     .03            0 Other

enq: TO - contention                              .03            0 Other

checkpoint completed                              .74            0 Configurati

                                                                   on



EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

GPnP Get Item                                     .15            0 Other

enq: SM -  contention                             .03            0 Other

enq: TD - KTF dump entries                        .03            0 Other

switch logfile command                           3.08            0 Administrat

                                                                   ive


GPnP Termination                                  .16            0 Other

kfk: async disk IO                                .13            0 System I/O

ADR block file write                                0            0 Other

parallel recovery coord wait for reply            .32            0 Other

enq: HW - contention                              .05            1 Configurati


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

                                                                   on


Log archive I/O                                   .13            1 System I/O

library cache load lock                           .58            1 Concurrency

enq: FB - contention                              .07            1 Other

kksfbc child completion                          4.24            1 Other

DIAG lock acquisition                            5.14            1 Other

PX Deq: Signal ACK EXT                              0            1 Other

enq: TA - contention                              .03            1 Other

enq: ZH - compression analysis                    .03            1 Other

rdbms ipc reply                                   .48            1 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

enq: TX - index contention                        .79            1 Concurrency

db file async I/O submit                            0            1 System I/O

enq: TS - contention                              .03            1 Other

local write wait                                   .7            1 User I/O

library cache: mutex X                            .05            1 Concurrency

CDB: Per Instance Query for PDB Info           101.76            1 Other

cursor: pin S wait on X                           .59            1 Concurrency

LGWR worker group ordering                         .1            1 Other

CSS operation: query                              .01            1 Other

enq: CR - block range reuse ckpt                  .22            2 Other

enq: WL - contention                             3.19            2 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

resmgr:internal state change                    10.24            2 Concurrency

recovery area: computing obsolete files         20.98            2 Other

gcs resource directory to be unfrozen            8.74            2 Other

control file single write                          .1            2 System I/O

SQL*Net more data from client                       0            2 Network

enq: JS - job run lock - synchronize              .04            2 Other

enq: TM - contention                              .06            2 Application

enq: RO - fast object reuse                       .06            2 Application

ges cgs registration                            20.22            3 Other

row cache cleanup                                   0            3 Other

buffer busy waits                                 .21            3 Concurrency


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

GPnP Initialization                              1.26            3 Other

enq: PV - syncstart                              6.43            3 Other

ges enter server mode                           38.61            3 Other

enq: TX - row lock contention                    2.69            4 Application

CSS operation: action                             .04            4 Other

undo segment extension                            .76            4 Configurati

                                                                   on


external table read                            408.28            4 User I/O

enq: CF - contention                              .47            4 Other

control file heartbeat                            409            4 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

enq: TC - contention                             8.08            4 Other

SQL*Net break/reset to client                       0            4 Application

direct path write temp                            .35            5 User I/O

row cache process                                   0            5 Other

ges lms sync during dynamic remastering          2.49            5 Other

and reconfig


library cache pin                                 .02            5 Concurrency

ksxr poll remote instances                          0            6 Other

flashback log file read                           .17            6 System I/O

enq: PR - contention                             2.48            6 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

ASM background starting                           .67            6 Other

gc current multi block request                    .04            7 Cluster

LGWR all worker groups                           1.98            7 Other

CSS initialization                                .13            7 Other

ges inquiry response                              .03            7 Other

gc buffer busy release                            .76            7 Cluster

enq: WF - contention                              .25            8 Other

CSS operation: data update                        .04            8 Other

CRS call completion                               3.7            9 Other

JS kgl get object wait                          10.24           10 Administrat

                                                                   ive


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------


CSS operation: data query                         .04           10 Other

latch free                                        .08           10 Other

enq: KO - fast object checkpoint                  .03           11 Application

libcache interrupt action by LCK                    0           11 Concurrency

ADR block file read                                 0           12 Other

DFS lock handle                                   .02           13 Other

gc cr block busy                                  .27           14 Cluster

gc cr grant 2-way                                 .02           15 Cluster

gc buffer busy acquire                            .16           15 Cluster

library cache lock                                .05           15 Concurrency


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

KSV master wait                                     0           23 Other

read by other session                              .2           27 User I/O

gc current block busy                              .5           28 Cluster

gcs log flush sync                                .32           28 Other

log file sequential read                          .38           29 System I/O

row cache lock                                    .01           29 Concurrency

gc current block 2-way                            .03           33 Cluster

gc current grant busy                             .05           34 Cluster

LGWR any worker group                            4.71           35 Other

os thread creation                                .09           36 Other

gc current grant 2-way                            .03           40 Cluster


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

PX Deq: Slave Session Stats                       .02           42 Other

gc cr block 2-way                                 .03           44 Cluster

ASM file metadata operation                       .01           45 Other

CGS wait for IPC msg                                0           49 Other

db file parallel read                            1.72           49 User I/O

SQL*Net more data to client                         0           51 Network

SQL*Net message to client                           0           56 Network

enq: PS - contention                              .03           61 Other

PX Deq: Slave Join Frag                           .04           65 Other

Disk file operations I/O                          .03           89 User I/O

direct path read                                  .35           91 User I/O


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

IPC send completion sync                          .02          112 Other

enq: IV -  contention                             .04          118 Other

target log write size                             .11          121 Other

name-service call wait                           7.67          169 Other

RMAN backup &amp; recovery I/O                        .26          182 System I/O

PX Deq: reap credit                                 0          195 Other

reliable message                                  .58          211 Other

log switch/archive                             756.42          219 Other

control file parallel write                       .07          233 System I/O

gc cr multi block request                         .04          332 Cluster

oracle thread bootstrap                          1.09          461 Other


EVENT                                    AVERAGE_WAIT TIME_SECONDS WAIT_CLASS

---------------------------------------- ------------ ------------ -----------

direct path write                                 .83          694 User I/O

db file parallel write                            .04          814 System I/O

gc cr disk read                                   .03        1,055 Cluster

control file sequential read                      .05        1,378 System I/O

log file sync                                     .08        1,443 Commit

flashback log file sync                           .42        1,455 User I/O

log file parallel write                           .08        1,602 System I/O

flashback log file write                           .4        1,700 System I/O

db file scattered read                             .2        3,245 User I/O

db file sequential read                           .04        3,521 User I/O


177 rows selected.

Total wait time by wait event class.

SQL&gt; col WAIT_CLASS format a25

col TIME_SECONDS format a25

SELECT WAIT_CLASS, TO_CHAR(ROUND(TIME_WAITED/100),'999,999,999') TIME_SECONDS

FROM V$SYSTEM_WAIT_CLASS

WHERE TIME_WAITED&gt;0 AND WAIT_CLASS&lt;&gt;'Idle'

ORDER BY TIME_WAITED;SQL&gt; SQL&gt;   2    3    4


WAIT_CLASS                TIME_SECONDS

------------------------- -------------------------

Configuration                        5

Administrative                      10

Application                         24

Concurrency                         69

Network                            110

Commit                           1,443

Cluster                          1,625

Other                            2,167

System I/O                       5,949

User I/O                         9,181


10 rows selected.

 Display the percentage for each wait class 

SQL&gt; col PCT format a5

SELECT WAIT_CLASS, TO_CHAR(ROUND(TIME_WAITED/100),'999,999,999') TIME_SECONDS,

'%' || ROUND(RATIO_TO_REPORT(TIME_WAITED) over ()*100) PCT

FROM V$SYSTEM_WAIT_CLASS

WHERE TIME_WAITED&gt;0 AND WAIT_CLASS&lt;&gt;'Idle'

ORDER BY TIME_SECONDSQL&gt; S;  2    3    4    5


WAIT_CLASS                TIME_SECONDS              PCT

------------------------- ------------------------- -----

Configuration                        5              %0

Administrative                      10              %0

Application                         24              %0

Concurrency                         69              %0

Network                            110              %1

Commit                           1,445              %7

Cluster                          1,628              %8

Other                            2,169              %11

System I/O                       5,952              %29

User I/O                         9,187              %45


10 rows selected.


Eg. Display the current sessions with the total wait time of the wait event 'log file sync' in each session


SQL&gt; set linesize 180

col EVENT format a25

SELECT E.SID, S.USERNAME, E.EVENT,

TO_CHAR(ROUND(E.TIME_WAITED/100),'999,999,999') TIME_SECONDS,

E.WAIT_CLASS

FROM V$SESSION_EVENT E, V$SESSION S

WHERE E.SID=S.SID AND ROUND(E.TIME_WAITED/100)&gt;0

SQL&gt; SQL&gt; AND S.USERNAME='SOE' AND E.EVENT='log file sync'

ORDER BY TIME_WAITED;  2    3    4    5    6    7

no rows selected

Current sessions which are currently waiting for the event 'log file sync'

SQL&gt; col USERNAME format a4

col WAIT_CLASS format a10

SELECT SID, USERNAME, EVENT, WAIT_TIME, WAIT_CLASS

FROM V$SESSION

WHERE USERNAME='SOE'

AND EVENT='log file sync'

ORDER BY WAIT_TIME;SQL&gt; SQL&gt;   2    3    4    5


no rows selected


SQL&gt;


SQL&gt; col USERNAME format a4

col WAIT_CLASS format a10

SELECT SID, USERNAME, EVENT, WAIT_TIME, WAIT_CLASS

FROM V$SESSION

WHERE USERNAME='INFODBA'

ORDER BY WAIT_TIME;SQL&gt; SQL&gt;   2    3    4


       SID USER EVENT                      WAIT_TIME WAIT_CLASS

---------- ---- ------------------------- ---------- ----------

         3 INFO SQL*Net message from clie          0 Idle

           DBA  nt


      1084 INFO SQL*Net message from clie          0 Idle

           DBA  nt


         7 INFO SQL*Net message from clie          0 Idle

           DBA  nt


        10 INFO SQL*Net message from clie          0 Idle

           DBA  nt


       SID USER EVENT                      WAIT_TIME WAIT_CLASS

---------- ---- ------------------------- ---------- ----------


        13 INFO SQL*Net message from clie          0 Idle

           DBA  nt


       160 INFO SQL*Net message from clie          0 Idle

           DBA  nt


       162 INFO SQL*Net message from clie          0 Idle

           DBA  nt


       164 INFO SQL*Net message from clie          0 Idle



</div>