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

 

Thursday, 23 January 2014

Generally used unix/linux commands in RAC Cluster



Generally used unix/linux commands in RAC Cluster

SRVCTL or Server Control Utility is used to start and stop the database and instances, manage configuration information, and to add, move or remove instances and services.
To Start a RAC database
srvctl start nodeapps -n <nodename>
srvctl start asm -n <nodename>
srvctl start database -d <dbname>
options: srvctl start database -d <dbname> -o open | -o mount | -o nomount

Stop a RAC database
srvctl stop database -d <dbname> -o immediate
options: srvctl stop database -d <dbname> -o normal | -o transactional | -o immediate | -o abort

srvctl stop asm -n <nodename>
options: srvctl stop asm -n <nodename> -o immediate

srvctl stop nodeapps -n <nodename>
To check status and configurations
Nodeapps:
srvctl status nodeapps -n <nodename>

srvctl config nodeapps -n <nodename>
ASM:
srvctl status asm -n <nodename>
srvctl config asm -n <nodename>

Database:
srvctl status database -d <dbname>
srvctl config database -d <dbname> (shows instances name, node and oracle home)

Instance:
srvctl status instance -d <dbname> -i instancename

Services:
srvctl status service -d <dbname>



To start and stop instances
srvctl start instance -d <dbname> -i instancename
srvctl stop instance -d <dbname> -i instancename

To start, stop and manage services
srvctl status service -d <dbname>
srvctl config service -d <dbname>
srvctl start service -d <dbname> -s servicename
srvctl stop service -d <dbname> -s servicename





#Disclaimer: - These commands are general purpose commands. Please contact me over mail or phone for implementing in any production System.


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

Tuesday, 14 January 2014

Creating A DB Link :-
-----------------------------------------------
create database link <DB Link Name> connect to <Username> identified by <Password> using 'Database Identifier';




Dropping a DB link :-
-----------------------------------------------
drop database link <DB Link Name>;

Simple query to Change the site name from back-end :-
-------------------------------------------------------------------------------
UPDATE FND_PROFILE_OPTION_VALUES set profile_option_value='<New Site Name>' where profile_option_id=125 and level_id=10001
/
commit
/
exit









#Note - The values may slightly change depending on environment.

Monday, 6 January 2014

Query to find all the concurrent programs running in any instance, execute this query in toad or sql/pl-sql developer to get the report in XL.

    SELECT fcr.request_id,
    fr.responsibility_name,
           DECODE(fcpt.user_concurrent_program_name,
                  'Report Set',
                  'Report Set:' || fcr.description,
                  fcpt.user_concurrent_program_name) CONC_PROG_NAME,
           argument_text PARAMETERS,
           NVL2(fcr.resubmit_interval,
                'PERIODICALLY',
                NVL2(fcr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE')) PROG_SCHEDULE_TYPE,
           DECODE(NVL2(fcr.resubmit_interval,
                       'PERIODICALLY',
                       NVL2(fcr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE')),
                  'PERIODICALLY',
                  'EVERY ' || fcr.resubmit_interval || ' ' ||
                  fcr.resubmit_interval_unit_code || ' FROM ' ||
                  fcr.resubmit_interval_type_code || ' OF PREV RUN',
                  'ONCE',
                  'AT :' ||
                  TO_CHAR(fcr.requested_start_date, 'DD-MON-RR HH24:MI'),
                  'EVERY: ' || fcrc.class_info) PROG_SCHEDULE,
           fu.user_name USER_NAME,
           requested_start_date START_DATE
      FROM apps.fnd_concurrent_programs_tl fcpt,
           apps.fnd_concurrent_requests    fcr,
           apps.fnd_user                   fu,
           fnd_responsibility_tl              fr,
           apps.fnd_conc_release_classes   fcrc
     WHERE fcpt.application_id = fcr.program_application_id
       AND fcpt.concurrent_program_id = fcr.concurrent_program_id
       AND fcr.requested_by = fu.user_id
       and fcr.responsibility_id=fr.responsibility_id
       AND fcr.phase_code = 'P'
       AND fcr.requested_start_date > SYSDATE
       AND fcpt.LANGUAGE = 'US'
       AND fcrc.release_class_id(+) = fcr.release_class_id
       AND fcrc.application_id(+) = fcr.release_class_app_id;


Mail me at - akash007.pramanik@gmail.com if you like this. Also feel free to comment for any issues.

Friday, 3 January 2014

Simple query to check Database locks:-
-----------------------------------------------------------
break on sid_serial;

SELECT l.session_id||','||v.serial# sid_serial,
       l.ORACLE_USERNAME ora_user,
       o.object_name,
       o.object_type,
       DECODE(l.locked_mode,
          0, 'None',
          1, 'Null',
          2, 'Row-S (SS)',
          3, 'Row-X (SX)',
          4, 'Share',
          5, 'S/Row-X (SSX)',
          6, 'Exclusive',
          TO_CHAR(l.locked_mode)
       ) lock_mode,
       o.status,
       to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
FROM dba_objects o, gv$locked_object l, v$session v
WHERE o.object_id = l.object_id
      and l.SESSION_ID=v.sid
order by 2,3;
Simple query to check Database growth in GB with respect to time---
-------------------------------------------------------------------------------------
select to_char(Trunc(creation_time,'MM'), 'MON RRRR') "Month",
sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where creation_time > SYSDATE-9999
group by Trunc(creation_time,'MM')
order by Trunc(creation_time,'MM');