Tuesday 28 January 2014




Oracle Database Performance Tuning for Beginners

Performance issue is one of the most challenging issues faced by a Database Administrator Everyday. I am providing the basic steps how to get started with the situation when our users start complaining about the Database running slow.

Ø      TOP Command:-
This command provides an ongoing look at processor activity in real time. Check for the Oracle processes which are consuming maximum CPU.





ü      Get the SID from PID:-
You may use this query to find the sid from the pid of the process. This query is simple, you may customize your own query using the objects v$session and v$process.

select sid
from v$session s, v$process p
where p.spid = <process Id>
and s.paddr = p.addr;




ü      Get the details of the waits:-
Find out the details of the wait from v$session_event

set lines 120 trimspool on
col event head "Waited for" format a30
col total_waits head "Total|Waits" format 999,999
col tw_ms head "Waited|for (ms)" format 999,999.99
col aw_ms head "Average|Wait (ms)" format 999,999.99
col mw_ms head "Max|Wait (ms)" format 999,999.99
select event, total_waits, time_waited*10 tw_ms,
       average_wait*10 aw_ms, max_wait*10 mw_ms
from v$session_event
where sid = 2844; ---à<put your SID>

ü      Output shall be like:-
 

Ø      Other objects which also provide important information are:-

V$ACTIVE_SESSION_HISTORY, V$SESSTAT, etc



Ø      These are the other OS commands which provide useful statistics.

ü      Check iostat:-
The iostat command gives the performance metrics of the storage interfaces.
 

ü      Check ipcs:-
When a process runs, it grabs from the “shared memory”. There could be one or many shared memory segments by this process. The processes send messages to each other (“inter-process communication”, or IPC) and use semaphores. To display information about shared memory segments, IPC message queues, and semaphores, you can use a single command: ipcs.

ü      Check free:-
One common question is, “How much memory is being used by my applications and various server, user, and system processes?” Or, “How much memory is free right now?” If the memory used by the running processes is more than the available RAM, the processes are moved to swap. So an ancillary question is, “How much swap is being used?”
The free command answers all those questions. What’s more, a very useful option, –m, and shows free memory in megabytes:-
 
There is much more in Database tuning, but I believe this document shall act as a good reference document for beginners in Oracle Database tuning.







Author – Akash Pramanik.
Database Administrator – IBM
Phone – +91 9804944189