Skip to main content

Posts

Showing posts from 2017

SQL queries to get the blocking session details in oracle database

Please find the sql queries below to get the details of db blocks. Check_db_blocks : ********************* set linesize 512 select v.instance_name ||' - '|| l1.sid ||' ('||s1.client_identifier||' - '||s1.module||')' || ' IS BLOCKING ' || l2.sid||' ('||s2.client_identifier||' - '||s2.module||')' || s1.sql_id || s1.username || s1.program || s1.machine "BLOCKING SESSIONS" from v$instance v, v$lock l1, v$lock l2, v$session s1, v$session s2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2 and l1.sid=s1.sid and l2.sid=s2.sid; Check_db_locks : ******************** set lines 100 select ' SID '|| sid||' ,Serial# '||serial#||' user '||username||' is getting blocked by SID '||blocking_session|| ' for last '||seconds_in_wait||' seconds and wait_event '||event||' for SQL_ID '||sql_id ||' (Locked_Object_ID '||row_wait_

SQL query to get the sessions causing high CPU usage on database (DB) server

If you are experiencing the high cpu usage on database (DB) server, you can use the below queries to track the session and sql details which are consuming high cpu resources in oracle database server. sessions based on cpu usage 1: ************************************ set pages 1000 set lines 1000 col OSPID for a06 col SID for 99999 col SERIAL# for 999999 col SQL_ID for a14 col USERNAME for a15 col PROGRAM for a23 col MODULE for a18 col OSUSER for a10 col MACHINE for a25 select * from ( select p.spid "ospid", (se.SID),ss.serial#,ss.SQL_ID,ss.username,substr(ss.program,1,22) "program",ss.module,ss.osuser,ss.MACHINE,ss.status,ss.BLOCKING_SESSION blk_sid,ss.BLOCKING_SESSION_STATUS blk_status, se.VALUE/100 cpu_usage_sec,ss.event from v$session ss, v$sesstat se, v$statname sn, v$process p where se.STATISTIC# = sn.STATISTIC# and NAME like '%CPU used by this session%' and se.SID = ss.SID and ss.username !='SYS' and ss.status=

Metrics Process Limit Usage percentage (%) is critical or warning in OEM or Cloud Control 12c or Cloud Control 13c

Please run the below queries to trace details during Metric alert "Process Limit % is >= 75" in OEM or Cloud Control 12c or Cloud Control 13c To check the Metrics Process Limit Usage (%): ***************************************************** set lines 300 col INITIAL_ALLOCATION for a17 col LIMIT_VALUE for a12 select resource_name,current_utilization,max_utilization, INITIAL_ALLOCATION,LIMIT_VALUE,((current_utilization*100)/(INITIAL_ALLOCATION)) as "Process limit %" from v$resource_limit where resource_name in ('processes'); The below query will give you all connected sessions (ACTIVE and INACTIVE) to instance: ******************************************************************************************************* set pages 100 set lines 1000 col SPID heading 'PID' for a06 col SID for 99999 col SERIAL# heading 'serial' for 999999 col SQL_ID for a14 col USERNAME for a10 col PROGRAM for a20 col MODULE for a18 col OSU

RMAN Job progress

To check the output of RMAN: ********************************** select sid,output from v$rman_output; To check backup status: *************************** set lines 1000 set pages 500 col OPERATION for a25 col STATUS for a30 col START_TIME for a18 col END_TIME for a18 col sid for 9999 select SID,RECID,STAMP,OPERATION,OBJECT_TYPE,STATUS,to_char(START_TIME,'dd-mm-yy hh24:mi:ss') START_TIME, to_char(END_TIME,'dd-mm-yy hh24:mi:ss') END_TIME,MBYTES_PROCESSED from v$rman_status order by RECID; To check backup status in last 24 hours: ********************************************* set lines 1000 set pages 500 col OPERATION for a25 col STATUS for a30 col START_TIME for a18 col END_TIME for a18 col sid for 9999 select RECID,STAMP,OPERATION,OBJECT_TYPE,STATUS,to_char(START_TIME,'DD-MON-YY HH24:MI:SS') START_TIME, to_char(END_TIME,'DD-MON-YY HH24:MI:SS') END_TIME,MBYTES_PROCESSED from v$rman_status WHERE START_TIME>=sysdate-1 order