Wednesday, March 17, 2010

About Oracle Wait Event....

"Wait Event" Defined
At any given moment, every Oracle process is either busy servicing a request or waiting for something specific to happen. By "busy" we mean that the process wishes to use the CPU. For example, a dedicated server process might be performing an arithmetic operation while executing a PL/SQL block. This process would be said to be busy and not waiting. The LGWR process, meanwhile, might be waiting for the operating system to indicate that the redo log buffer has successfully been written to disk. In this case the LGWR process is waiting.

The kernel developers at Oracle have defined a list of every possible event that an Oracle process could be waiting for. In Oracle 8.0 there were 158 such wait events. In Oracle 8i Release 3 there are 217. At any moment, every Oracle process that is not busy is waiting for one of these events to occur. Suppose a dedicated server process is waiting for an application to submit a SQL statement for execution. This wait event is called "SQL*Net message from client." Another dedicated server process might be waiting for a row-level lock on the INVOICES table to be freed so that an UPDATE statement can continue. That wait event is called "enqueue."
It turns out that Oracle is very diligent about tracking wait event information and making it available to DBAs. We call this the "wait event interface." By querying v$ views, we can see what events processes are waiting on to an amazing level of detail


following query can be used to find out which session is requesting the lock, the type and mode of the requested lock and the session that is blocking the request:
SELECT DECODE(request,0,'Holder: ','Waiter: ')sid sess, id1, id2, lmode, request, typeFROM V$LOCKWHERE (id1, id2, type) IN (SELECT id1, id2, type FROM V$LOCK WHERE request>0)ORDER BY id1, request
The following are examples of the types of locks:
TX
This enqueue is a transaction lock and is typically caused by incorrect application logic or table setup issues.
TM
This enqueue represents a DML lock and is generally due to application issues, particularly if foreign key constraints have not been indexed.
ST
When Oracle performs space management operations (such as allocating temporary segments for a sort, allocating extents for a table, etc), the user session waits on the 'ST' enqueue.

nice explanation can found on below Links..

http://www.dbspecialists.com/files/presentations/wait_events.html

http://www.dbspecialists.com/files/presentations/wait_events_10g.html