December 17, 2021

Find Concurrent Program Run History from backend

Query to find concurrent program run history and status


SELECT f.request_id,
         pt.user_concurrent_program_name
             user_conc_program_name,
         f.actual_start_date
             start_on,
         f.actual_completion_date
             end_on,
         p.concurrent_program_name
             concurrent_program_name,
         DECODE (f.phase_code,
                 'R', 'RUNNING',
                 'C', 'COMPLETED',
                 f.phase_code)
             phase,
         DECODE (f.status_code,  'C', 'NORMAL',  'E', 'ERROR',  f.status_code)
             Status,
         f.requested_by,
         fu.user_id,
         fu.user_name
    FROM apps.fnd_concurrent_programs   p,
         apps.fnd_concurrent_programs_tl pt,
         apps.fnd_concurrent_requests   f,
         apps.fnd_user                  fu
   WHERE     f.concurrent_program_id = p.concurrent_program_id
         AND f.program_application_id = p.application_id
         AND f.concurrent_program_id = pt.concurrent_program_id
         AND f.program_application_id = pt.application_id
         AND pt.language = USERENV ('lang')
         AND f.actual_start_date IS NOT NULL
         AND f.actual_start_date >
             TO_DATE ('15-DEC-2021 00:00:00', 'DD-MON-YYYY HH24:MI:SS')
         AND f.actual_completion_date <
             TO_DATE ('17-DEC-2021 23:59:59', 'DD-MON-YYYY HH24:MI:SS')
         AND f.requested_by = fu.user_id
         AND pt.USER_CONCURRENT_PROGRAM_NAME = '&User_concurrent_program_name'
--AND fu.user_name = '&user_name'
ORDER BY f.actual_start_date ASC; 

##Change the date accordingly.

December 15, 2021

Temp Tablespace Usage

Oracle Temp Tablespace usage


Check for Temp tablespace usage


set lin 200;
col file_name for a75;
col autoextensible for a15;

select file_name,tablespace_name,sum(bytes)/1024/1024 as FILE_SIZE,sum(maxbytes)/1024/1024 as MAX_SIZE,autoextensible from dba_temp_files
where tablespace_name ='TEMP' group by file_name,tablespace_name,autoextensible order by file_name;


Data file usage of a tablespace

Oracle Tablespaces 

Check Data File Size in any given Tablespace (Dynamic) :

set lin 200;
col file_name for a75;
col autoextensible for a15;

select file_name,tablespace_name,sum(bytes)/1024/1024 "FILE_SIZE(MB)",sum(maxbytes)/1024/1024 as MAX_SIZE,autoextensible from dba_data_files
where tablespace_name ='&tablespace_name' group by file_name,tablespace_name,autoextensible order by file_name;

December 09, 2021

Query to find Tablespace utilization in Oracle Database

Oracle Tablespace Utilization

Find the tablespace utilization on Oracle Database (10g,11g,12c,19c)


column file_name format a45
column tablespace_name format a10
col tablespace_name for a40
set verify off
set pages 3000
set line 3000

 

SELECT  dts.tablespace_name, 

NVL(ddf.bytes / 1024 / 1024, 0) avail,

NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024 used,
NVL(dfs.bytes / 1024 / 1024, 0) free,
TO_CHAR(NVL((ddf.bytes - NVL(dfs.bytes, 0)) / ddf.bytes * 100, 0), '990.00') "Used %" ,
TO_CHAR(NVL((ddf.bytes - NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)) / ddf.bytes* 100, 0), '990.00') free_pct,
decode(sign((NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.90 - NVL(ddf.bytes/1024/1024, 0)),-1,0,
(NVL(ddf.bytes - NVL(dfs.bytes, 0), 0)/1024/1024)/0.90 - NVL(ddf.bytes / 1024 / 1024, 0))  "Required MB" FROM
sys.dba_tablespaces dts,
(select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) ddf,
(select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) dfs
WHERE
dts.tablespace_name = ddf.tablespace_name(+)
AND dts.tablespace_name = dfs.tablespace_name(+)
order by free_pct;

Best Wishes!!

December 02, 2021

Find session details sid/pid from concurrent request id

Oracle Performance Analysis - Long running Concurrent Requests

The following query can be used to find the sid,pid, spid for a specific concurrent request. If a program is running for long time and user requests to verify the root cause, this will help DBA to find the sid and then dba can go beyond this and look for sqlid, plan etc. This will be helpful while doing performance analysis


SELECT a.request_id,
       d.sid,
       d.serial#,
       d.sql_id,
       d.osuser,
       d.process,
       d.client_identifier "requestor" ,
       c.SPID
  FROM apps.fnd_concurrent_requests   a,
       apps.fnd_concurrent_processes  b,
       v$process c,
       v$session d
 WHERE     a.controlling_manager = b.concurrent_process_id
       AND c.pid = b.oracle_process_id
       AND b.session_id = d.audsid
       AND a.request_id = '&REQUEST_ID';


 

December 01, 2021

Create/update sql profile/ sql baseline in Oracle Database

Oracle Performance Tuning

How to create SQL baseline in Oracle database from the backend. 


1. Check for baseline if available, from the SQL-ID


SELECT sql_handle, plan_name, enabled, ACCEPTED,FIXED,created FROM dba_sql_plan_baselines WHERE signature IN ( SELECT exact_matching_signature FROM gv$sql WHERE sql_id='&SQL_ID');


or


SELECT b.sql_handle, b.sql_text, b.plan_name, b.enabled
 FROM   dba_sql_plan_baselines b, v$sql s
 WHERE  s.sql_id='&SQL_ID'
 AND    s.exact_matching_signature = b.signature;


2. Now load the baselines from cursor (If nothing suitable is available on the Query 1):


DECLARE
    ezplan NUMBER;
 BEGIN
    ezplan := sys.dbms_spm.load_plans_from_cursor_cache(sql_id=>'&SQL_ID');
 END;
 /


3. Next, run the select again to see how many are imported and which one is good plan:

SELECT sql_handle, plan_name, enabled, ACCEPTED,FIXED,created FROM dba_sql_plan_baselines WHERE signature IN ( SELECT exact_matching_signature FROM gv$sql WHERE sql_id='&SQL_ID');


If it is returning multiple rows, means multiple plans are available for this SQL-ID.

To check the cost and plans for individual plans run the below script:

from Cursor:

select plan_table_output from table(dbms_xplan.display_cursor('<sql_id>',null,'ADVANCED'));

Recent Post

Check progress on expdp and impdp

 Check progress on expdp and impdp: In few cases we need to monitor the progress of an export or import job in oracle. below are the steps c...