Wednesday 24 February 2016

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Source: Windows 32-bit

Target Linux 64-bit

Small guide what I am going to do:

Steps:
1. Check platform compatibility between Source and target OS
2. Start the database in read only mode
3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB
4. Check if there are any external objects
5. Execute the RMAN Convert database command
6. Copy Converted datafiles, Generated Script and Pfile to Linux
7. Edit the Pfile for the new database (Linux)
8. Edit the Transport Script and Pfile changing the windows paths to Linux Paths.
9. Execute the Transport Script on Linux
10. Change the DBID
11. Run utlirp.sql and utlrp.sql for recompile all Pl/SQL modules.
12. Verify & Compare the database on Linux

Source:
Step 1:
====

SQL> Select * from v$transportable_platform order by platform_id;

Here both will (Windows and Linux endian format is little only)
Check the Version of database:
SQL> select * from v$version;
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 – Production

Note: Kindly check it Target server pre-requesite install software only




Step 2:

2. Start the database in read only mode

> shut immediate;
>startup mount;

> alter database open read only;



Step 3:

3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB

Note:
Before converting the database, we have to be make sure that whether a database can be transported to a desired destination platform, and whether the current state of the database permits transport. We check this using "DBMS_TDB.CHECK_DB" procedure.
If this procedure returns "FALSE" then the output includes the reason why the database cannot be transported like target platform has a different endian format, database is not open read-only, there are active transactions in the database, database compatibility version is below 10 etc.

set serveroutput on
declare
db_ready boolean;
begin
db_ready := dbms_tdb.check_db('Linux x86 64-bit');
end;
/
PL/SQL procedure successfully completed.
Note: If database is not open in read-only mode, then the above procedure may return error like Database is not open READ ONLY. Please open database READ ONLY and retry.

Step 4:

Check if there are any external objects:

Note:

If there is any external objects take note of them, they will need to be taken care manually because RMAN cannot automate the transport of such objects. "DBMS_TDB.CHECK_EXTERNAL" must be used to identify any external tables, directories or BFILEs.

set serveroutput on
declare
external boolean;
begin
external := dbms_tdb.check_external;
end;
/

The following directories exist in the database:
SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR, SYS.XMLDIR

Note:

No need to worry its automatically taking when we start using pfile in Target

Step 5

5. Using the RMAN CONVERT DATABASE:
After all the pre-requisites have been performed successfully, we can use the RMAN CONVERT DATABASE command to generate the output files for the target database. While executing the CONVERT DATABASE command, we need to specify the new database name, the destination platform, path to save the transport script and optionally a path, where to save the output files.
Note: If you omit the "DB_FILE_NAME_CONVERT" clause, the output files are created in

"C:\ORACLE_HOME\database" folder.
C:\>rman target /


CONVERT DATABASE NEW DATABASE 'migra'
transport script 'd:\app\mig\script.sql'
to platform 'Linux x86 64-bit'
db_file_name_convert 'D:\app\kumar\oradata\prod500\' 'D:\app\mig\';

output:

Starting conversion at source at 23-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=D:\APP\KUMAR\ORADATA\PROD500\SYSTEM01.DBF
converted datafile=D:\APP\TRANS\SYSTEM01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=D:\APP\KUMAR\ORADATA\PROD500\SYSAUX01.DBF
converted datafile=D:\APP\TRANS\SYSAUX01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS01.DBF

converted datafile=D:\APP\TRANS\UNDOTBS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS02.DBF

converted datafile=D:\APP\TRANS\UNDOTBS02.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=D:\APP\KUMAR\ORADATA\PROD500\USERS01.DBF
converted datafile=D:\APP\TRANS\USERS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Edit init.ora file D:\APP\KUMAR\PRODUCT\11.2.0\DBHOME_1\DATABASE\INIT_00PE587E_1
_0.ORA. This PFILE will be used to create the database on the target platform
Run SQL script D:\APP\TRANS\SCRIPT.SQL on the target platform to create database

To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target plat
form
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 23-JUL-14



Note:

I all my converting datafiles,scripts file,exe file will store in this location


=D:\app\mig\

But my Init.ora file store in at $ORACLE_HOME take copy of this file also.

Move this Mig file to Linux server:


Note:

Source completed copy all the move to Window server to linux server

Phase -II – Target server (Linux):


6. Copy Converted Datafiles, Generated Script and Pfile to the Linux Machine:
Now copy these converted datafiles, transport script and Pfile on the Linux server. Do not forget to create necessary folder on linux machine such as adump, bdump, udump, cdump, flash_recovery_area.

Note:
Since we are those parameter in not ther in migrate init.ora parameter

c:/app/mig/ move to Linux /oracle/u01/oradata/


Phase -II – Target server (Linux)

7. Edit init.ora or pfile for new database:
Open the init.ora file generated by RMAN. The first section of pfile must be updated, others are optional. Change all the absolute path of windows environment to absolute path of Linux environment.

Note:
Since we are those parameter in not ther in migrate init.ora parameter
control_files = "/oracle/u01/oradata/mig/CF_D-MIGRA_ID-2500231993_01PEOM3D"

db_recovery_file_dest = "/oracle/u01/oradata/mig/flash_recovery_area"

db_recovery_file_dest_size= 4039114752

audit_file_dest = "/oracle/u01/oradata/mig/ADUMP"

db_name = "MIGRA"

oracle_base = "/oracle/u01/

remote_login_passwordfile= "EXCLUSIVE"

db_domain = ""

dispatchers = "(PROTOCOL=TCP) (SERVICE=migra500XDB)"

__pga_aggregate_target = 318767104



# The values of the following parameters are from source database:

processes = 150

memory_target = 855638016
diagnostic_dest = "/oracle/u01"

Once Completed editing Init.ora file:

8. Edit The Script:
Before running the transport script on the target Linux server we need to edit it to set the correct paths for pfile, datafiles, logfiles and tempfiles. Update all the paths as per your Linux environment.

STARTUP NOMOUNT PFILE='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "MIGRA" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-34_T-1_A-850908222_03PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-32_T-1_A-850908222_04PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-33_T-1_A-850908222_05PEOM3D' SIZE 50M BLOCKSIZE 512
DATAFILE
'/oracle/u01/oradata/mig/SYSTEM01.DBF',
'/oracle/u01/oradata/mig/SYSAUX01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS01.DBF',
'/oracle/u01/oradata/mig/USERS01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS02.DBF'
CHARACTER SET WE8MSWIN1252
;
9. Execute the Script:

Set Environment:

export PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oradb/bin:/oracle/u01/product/11.2.0/dbhome_1/bin:/oracle/u01/product/11.2.0/dbhome_1/OPatch

export ORACLE_SID=MIGRA
export ORACLE_HOME=/oracle/u01/product/11.2.0/dbhome_1


> sqlplus / as sysdba

>@/oracle/u01/mig/SCRIPT.sql

Crated database

>alter database open resetlogs;


ii) once this completed as per SCRIPT.SQL add temporary tablespace since RMAN
didn;t take covert this temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;
(or)
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
2 size 5m;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]

Cause:


There no temp file and sql statement not getting executed,
since this problem for packege file so we have to run = utlirp.sql


solve:
=====

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
ORACLE instance started.

Total System Global Area 851808256 bytes
Fixed Size 2218112 bytes
Variable Size 641730432 bytes
Database Buffers 201326592 bytes
Redo Buffers 6533120 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> select logins from v$instance;

LOGINS
----------
RESTRICTED

SQL> select status from v$instance;

STATUS
------------
OPEN MIGRATE

>@$ORACLE_HOME/rdbms/admin/utlirp.sql

Once comeplete


Once its completed create temporary tablespace since I am going to run utlrp.sql so
that time should need temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;


iii) Run utlrp.sql for compile invalid object:

> shut immediate
>startup pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
>@$ORACLE_HOME/rdbms/admin/utlrp.sql

Error:
====

RROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 6923
Session ID: 201 Serial number: 165

ERROR:
ORA-03114: not connected to ORACLE

Chacking alert.log file need to extend temporay tablespace

solve:

Add new datafile in the temporary tablespace


iv) Error:
======

> shut immediate;

ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist

solution:

Creating Tnsname.ora entry

MIGRA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = migra)
)
)

cross-check:

]$tnsping migra
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = migra)))
OK (10 msec)

=====================================

What is UTLIRP.SQL ?
This is a SQL script which first Invalidates & then recompiles PL/SQL modules viz.,
procedures, functions, packages, types, triggers, views in a database
This script expects standard.sql, dbmsstdx.sql files to be available in the current directory.
There should be no other DDL on the database while running the script.

Note: mostly this run it at database in upgrade mode only, only migration time or cross-platform time we run this one.

+ What UTLIRP.SQL does?
The utlirp.sql script recompiles existing PL/SQL modules in the FORMAT required
by the NEW DATABASE with the below steps:
=======================================

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production


SQL> select * From dba_directories;

OWNER DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS ORACLE_OCM_CONFIG_DIR
D:\app\kumar\product\11.2.0\dbhome_1\ccr\state

SYS DATA_PUMP_DIR
D:\app\kumar\admin\prod500\dpdump\

SYS XMLDIR
c:\ade\aime_dadvfm0254\oracle\rdbms\xml


SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
TEMP_MIG

6 rows selected.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/oracle/u01/oradata/mig/UNDOTBS02.DBF
/oracle/u01/oradata/mig/USERS01.DBF
/oracle/u01/oradata/mig/UNDOTBS01.DBF
/oracle/u01/oradata/mig/SYSAUX01.DBF
/oracle/u01/oradata/mig/SYSTEM01.DBF

SQL> SELECT COMP_NAME,STATUS FROM DBA_REGISTRY;


Successfully Migration Done :



Thanks & Regards

Kumaresan Nethaji


Follow Document:



Youtube.com--> converting oracle database windows to Linux

Friday 19 February 2016

How to kill long running/hang concurrent request

How To Kill runaway processes After Terminating
==============================================

Concurrent Request:

Every concurrent Request uses some resources for running. If we find that the
concurrent request is taking long time and decided to terminate the concurrent
request , the resources may not be released soon. These processes are called
runaway processes. So we need to manually kill the processes at database and os
level to have the resources released to the system.
Terminate the concurrent request from the front end. Then

SQL>select request_id,oracle_process_id,os_process_id from
fnd_concurrent_requests where request_id=’&Req_Id’;


SQL>select p.spid , s.sid , s.serial# from v$session s , v$process p where s.paddr
= p.addr and s.process = &os_process_id ;

SQL> alter system kill session ‘session-id,session-serial’


$ kill -9 <server pid>


Complete details about the request can be found using the following query :
SELECT qt.user_concurrent_queue_name
, fcr.Request_Id Request_id
, fu.User_name
, p.spid
, s.sid ||’, ‘|| s.serial# SIDSERIAL
, substr( Fcpv.Concurrent_Program_Name ||’ – ‘||
Fcpv.User_Concurrent_Program_Name, 1,46) Program
, to_char( fcr.actual_start_date, ‘mm/dd hh24:mi’ ) actual_start_date
, phase_code, status_code
, to_char( trunc(sysdate) + ( sysdate – fcr.actual_start_date )
, ‘hh24:mi:ss’ ) duration
FROM apps.Fnd_Concurrent_Queues Fcq
, apps.fnd_concurrent_queues_tl qt
, apps.Fnd_Concurrent_Requests Fcr

Source –http://appsdba.info
, apps.Fnd_Concurrent_Programs Fcp
, apps.Fnd_User Fu
, apps.Fnd_Concurrent_Processes Fpro
, v$session s
, v$process p
, apps.Fnd_Concurrent_Programs_Vl Fcpv
WHERE phase_code = ‘C’
AND status_Code = ‘X’
AND s.paddr = p.addr
AND fcr.requested_by = user_id
AND fcq.application_id = qt.application_id
AND fcq.concurrent_queue_id = qt.concurrent_queue_id
AND userenv(’lang’) = qt.language
AND fcr.os_process_id = s.process
AND fcr.Controlling_Manager = Concurrent_Process_Id
AND (fcq.concurrent_queue_id = fpro.concurrent_queue_id
AND fcq.application_id = fpro.queue_application_id )
AND (fcr.concurrent_program_id = fcp.concurrent_program_id
AND fcr.program_application_id = fcp.application_id )
AND (fcr.concurrent_program_id = fcpv.concurrent_program_id
AND fcr.program_application_id = fcpv.application_id )
ORDER BY fcr.actual_start_date;





========================*********************=======================================

How to kill long running/hang concurrent request
================================================

When concurrent program taking more cpu utlization and can't open front-end application also that time we are going to this activity.


SELECT ses.sid,
ses.serial#
FROM v$session ses,
v$process pro
WHERE ses.paddr = pro.addr
AND pro.spid IN (SELECT oracle_process_id
FROM fnd_concurrent_requests
WHERE request_id =11613265);


You will get spid & pid from above request. Pass your request id in above query.


And run below query with sys user.





SQL> ALTER SYSTEM KILL SESSION ' 1114, 8017' IMMEDIATE;

System altered.


Issue: Request is in pending from long time,




Action:
#First Terminate the Request as follows

update fnd_concurrent_requests
   set status_code='X', phase_code='C'
   where request_id=31783706;

commit;

#Then change the status with Completed-Error as follows.

update fnd_concurrent_requests
   set status_code='E', phase_code='C'
   where request_id=31783706;

commit;

#This will change the status of any request.
#Status Code
E -  Error
X -  Terminate
G -  Warning




===============


(or)


Find below query and Kill oracle_process_id and Os_process_id

SELECT DISTINCT c.USER_CONCURRENT_PROGRAM_NAME,oracle_process_id,os_process_id,
      round(((sysdate-a.actual_start_date)*24*60*60/60),2) AS Process_time,
    a.request_id,a.parent_request_id,a.request_date,a.actual_start_date,a.actual_completion_date,
      (a.actual_completion_date-a.request_date)*24*60*60 AS end_to_end,
      (a.actual_start_date-a.request_date)*24*60*60 AS lag_time,
      d.user_name, a.phase_code,a.status_code,a.argument_text,a.priority
FROM     apps.fnd_concurrent_requests a,
    apps.fnd_concurrent_programs b ,
    apps.FND_CONCURRENT_PROGRAMS_TL c,
    apps.fnd_user d
WHERE   a.concurrent_program_id=b.concurrent_program_id AND
    b.concurrent_program_id=c.concurrent_program_id AND
    a.requested_by=d.user_id AND
    status_code='R' order by Process_time desc;


kill -9 <oracle_process_id>

kill -9 <os_process_id>
 
 
 update fnd_concurrent_requests set status_code='X', phase_code='C' where request_id='21889851';

Thursday 18 February 2016

Tuning PGA memory


Tuning PGA Memory – Oracle database 10g
--------------------------------------------------


Correct size of PGA
====================

You can get the correct size of PGA using V$PGA_TARGET_ADVICE, dynamic performance view.


 SELECT ROUND(pga_target_for_estimate/1024/1024) target_mb,
 estd_pga_cache_hit_percentage cache_hit_perc,
 estd_overalloc_count
 FROM V$PGA_TARGET_ADVICE;



Checking PGA for each sessions:
================================

You can check session level PGA using V$SESSTAT and V$SESSION view and also you can check the username, who is using

that memory.

 SELECT
s.value,s.sid,a.username
FROM
V$SESSTAT S, V$STATNAME N, V$SESSION A
WHERE
n.STATISTIC# = s.STATISTIC# and
name = 'session pga memory'
AND s.sid=a.sid
ORDER BY s.value;



To check the total PGA in use and hit ratio for PGA:
==================================================

SQL> SELECT * FROM V$PGASTAT;


The ideal way to perform sorts is by doing the entire job in memory. A sort job that Oracle performs entirely in memory

is said to be an optimal sort. If you set the PGA_AGGREGATE_TARGET too low, some of the sort data is written out

directly to disk (temporary tablespace) because the sorts are too large to fit in memory. If only part of a sort job

spills over to disk, it’s called a 1-pass sort. If the instance performs most of the sort on disk instead of in memory,

the response time will be high. This is called multi pass sort.

Another method of checking the efficiency of PGA memory is to check V$SQL_WORKAREA_HISTOGRAM.

V$SQL_WORKAREA_HISTOGRAM displays the cumulative work area execution statistics (cumulated since instance startup) for

different work area groups. The work areas are split into 33 groups based on their optimal memory requirements with the

requirements increasing in powers of two. That is, work areas whose optimal requirement varies from 0 KB to 1 KB, 1 KB

to 2 KB, 2 KB to 4 KB, … and 2 TB to 4 TB.

For each work area group, the V$SQL_WORKAREA_HISTOGRAM view shows how many work areas in that group were able to run in

optimal mode, how many were able to run in one-pass mode, and finally how many ran in multi-pass mode. The DBA can take

a snapshot at the beginning and the end of a desired time interval to derive the same statistics for that interval.


SELECT
low_optimal_size/1024 “Low (K)”,
(high_optimal_size + 1)/1024 “High (K)”,
optimal_executions “Optimal”,
onepass_executions “1-Pass”,
multipasses_executions “>1 Pass”
FROM v$sql_workarea_histogram
WHERE total_executions <> 0;




You can check the proportion of work areas since you started the Oracle instance, using optimal, 1-pass, and multipass

PGA memory sizes.


SELECT name PROFILE, cnt COUNT,
DECODE(total, 0, 0, ROUND(cnt*100/total)) PERCENTAGE
FROM (SELECT name, value cnt, (sum(value) over ()) total
FROM V$SYSSTAT
WHERE name like 'workarea exec%');


PROFILE COUNT PERCENTAGE
————————————————– ———- ———-
workarea executions – optimal 6650608 100
workarea executions – onepass 2 0
workarea executions – multipass 0 0

Since almost all the sorting and temporary operation are carried out inder optimal catagory we can conclude that out

PGA is sized correctly.


Thursday 11 February 2016

Concurrent Tuning Scripts

find os process id
=====================================

select p.spid,s.sid,s.serial#,s.username,s.status,s.last_call_et,p.program,p.terminal,logon_time,module,s.osuser
from V$process p,V$session s
where s.paddr = p.addr and s.status = 'ACTIVE' and s.username not like '%SYS%';

to find locked session
===============================================

select * from v$session where sid IN (select session_id from dba_locks where blocking_others like 'Blocking%');

select * from v$session where blocking_session='NOTNULL';

to find sql hash value,sql id
============================================

select process,sql_hash_value,module,program,event,wait_class,vs.* from v$session vs where type !='BACKGROUND' and sid='259';

to find long running session
============================================

select * from v$session_longops where sid=2781;

to find which sql executing
==============================================

select * from v$sql where sql_id='9rxxntrr9fk0r';

to find what are the sql executed
====================================================

select * from v$sql_plan where sql_hash_value=4002891799;


To find sid from concurrent request
========================================================

select * from fnd_concurrent_requests where request_id='20774172';

select * from v$session where audsid='30762086';  --audsid is oracle session id


to find long Running Concurrent
===========================================================


SELECT a.request_id
,a.oracle_process_id "SPID"
,frt.responsibility_name
,c.concurrent_program_name || ': ' || ctl.user_concurrent_program_name
,a.description
,a.ARGUMENT_TEXT
,b.node_name
,b.db_instance
,a.logfile_name
,a.logfile_node_name
,a.outfile_name
,q.concurrent_queue_name
,a.phase_code,a.status_code, a.completion_text
, actual_start_date
, actual_completion_date
, fu.user_name
,(nvl(actual_completion_date,sysdate)-actual_start_date)*1440 mins
,(SELECT avg(nvl(a2.actual_completion_date-a2.actual_start_date,0))*1440 avg_run_time
FROM APPLSYS.fnd_Concurrent_requests a2,
APPLSYS.fnd_concurrent_programs c2
WHERE c2.concurrent_program_id = c.concurrent_program_id
AND a2.concurrent_program_id = c2.concurrent_program_id
AND a2.program_application_id = c2.application_id
AND a2.phase_code || '' = 'C') avg_mins
,round((actual_completion_date - requested_start_date),2) * 24 duration_in_hours
FROM APPLSYS.fnd_Concurrent_requests a,APPLSYS.fnd_concurrent_processes b
,applsys.fnd_concurrent_queues q
,APPLSYS.fnd_concurrent_programs c
,APPLSYS.fnd_concurrent_programs_tl ctl
,apps.fnd_user fu
,apps.FND_RESPONSIBILITY_TL frt
WHERE a.controlling_manager = b.concurrent_process_id
AND a.concurrent_program_id = c.concurrent_program_id
AND a.program_application_id = c.application_id
AND a.phase_code = 'R'
AND a.status_code = 'R'
AND b.queue_application_id = q.application_id
AND b.concurrent_queue_id = q.concurrent_queue_id
AND ctl.concurrent_program_id = c.concurrent_program_id
AND a.requested_by = fu.user_id
AND a.responsibility_id = frt.responsibility_id
ORDER BY a.actual_start_date DESC;

During Patch execution Activity
--------------------------------------------------------
select * from apps.AD_PARALLEL_updates where script_name like 'adobjcmp.sql';

SELECT * FROM APPS.AD_PARALLEL_UPDATE_UNITS WHERE UPDATE_ID=6544 AND STATUS='A'

SELECT count(*) FROM APPS.AD_PARALLEL_UPDATE_UNITS WHERE UPDATE_ID=1454 --AND STATUS='A'

select * from dba_objects where object_id=27505

select count(*) from dba_objects where status='INVALID'


======================================



TKM Project:
=============


Base concurret request find DB access information:
==================================================

 select event,program,blocking_session,row_wait_obj#,row_wait_block#,SQL_HASH_VALUE,vs.* from v$session vs where audsid in (select oracle_session_id
   from fnd_concurrent_requests where request_id in ('2104772','2104771','2104770','2104769'));


Based on above query given:
==========================

 select
c.owner,
c.object_name,
c.object_type,
b.sid,
b.serial#,
b.status,
b.osuser,
b.machine
from
v$locked_object a ,
v$session b,
dba_objects c
where
b.sid = a.session_id
and
a.object_id = c.object_id;
 
 
   SELECT SQL_FULLTEXT FROM V$SQL
   WHERE HASH_VALUE=2323454545;---2323454545---529293362---529293362
 
 select * from dba_objects where object_id='332714';


select address, hash_value from v$sqlarea where sql_id like '8uk2jxy57u6kj';
 
  exec dbms_shared_pool.purge('0000000523894160,2323454545','C');
 
   529293362
   529293362
  select * From v$sess_io where sid in (2329, 2106, 2147);


"SELECT NVL(SUM(prb.balance_value),0) FROM /* IN Assignment for Run RB */
  /* $Header: peinroutes.ldt 120.0.12010000.6 2013/02/07 12:19:07 pthummal noship $ */
        pay_run_balances            prb,
        pay_defined_balances        pdb
  where pdb.balance_type_id    = :U1
    AND pdb.balance_dimension_id = :U2
    AND pdb.defined_balance_id   = prb.defined_balance_id
    AND prb.assignment_action_id = :ASSIGNMENT_ACTION_ID"



 
   SELECT a.request_id, d.sid, d.serial# ,d.osuser,d.process , c.SPID ,d.inst_id
FROM apps.fnd_concurrent_requests a,
apps.fnd_concurrent_processes b,
gv$process c,
gv$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 =&req_id
AND a.phase_code = 'R';

1843

select * from v$session where sid=1843;


select * From fnd_concurrent_requests where request_id=2100226;



2160 2697
2124 25744
2112 11071
2213 31857

session after killed its showed it status=killed:
================================================

select * From v$session where sid=1961;

  paddr 00000005E8D79FC0

  select * From v$process where addr='00000005E8D79FC0';

 spid :  13707


kill - 9


================================================

Objects locked:

select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from
(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a,
(select object_id, owner, object_name,object_type from dba_objects) b
where a.object_id=b.object_id;

SELECT c.owner, c.object_name, c.object_type, b.SID, b.serial#, b.status,
       b.osuser, b.machine
  FROM v$locked_object a, gv$session b, dba_objects c
 WHERE b.SID = a.session_id
   AND a.object_id = c.object_id
   AND b.status = 'INACTIVE';

SELECT c.owner, c.object_name, c.object_type, b.SID, b.serial#, b.status,
       b.osuser, b.machine
  FROM v$locked_object a, gv$session b, dba_objects c
 WHERE b.SID = a.session_id
   AND a.object_id = c.object_id
   AND b.status = 'ACTIVE';



select event,program,blocking_session,row_wait_obj#,row_wait_block#,SQL_HASH_VALUE,vs.* from v$session vs where audsid in (select oracle_session_id
   from fnd_concurrent_requests where request_id in ('2104202','2104201','2104200','2104199'));

Concurrent Analyzer scripts

Concurrent Processing - CP Analyzer Sample SQL Statements Including Date Range Parameters from Doc
1411723.1- Concurrent Processing -
CP Analyzer for E-Business Suite (Doc ID 1499538.1)/:
===========================================================



Click to add to Favorites Concurrent Processing - CP Analyzer Sample SQL Statements Including Date Range Parameters from Doc 1411723.1- Concurrent Processing - CP Analyzer for E-Business Suite (Doc ID 1499538.1) To BottomTo Bottom

In this Document
Purpose
Troubleshooting Steps
  Script Provides Daily Concurrent Request Counts Completed by Hour
  Script Provides the Concurrent Requests Counts, Time, and Range
  Script Provides the Count by Name and Date
  Script Provides the Count of Requests Completed and Canceled
  Script Provides the Count of Requests Completed with Error
  Script Provides the Count of Requests Pending and Scheduled
  Script Provides the Count of Requests Terminated by Date
  Script Provides the Count of Requests by Date
  Quick Sql Statement to check Average Monthly Requests
  Script Identifying Concurrent Managers Used and Compare
  Elapsed Time History for All Requests Run for a Given Time Period
  Select for Providing Frequency/Volume Analysis Program Name, Queue Name, and Count by Program Name and Date Range
  Request Volume Per Day Select which can be Modified with Additions to the Where Clause
  Select Providing the Volume of Concurrent Requests Per Node
  Select reflecting All Requests with Run Times > 30 Minutes During Peak Load in the Past Month by Application_Id
  Select Providing Request ID's for Requests that are Currently Running
  Session Information Available from an Oracle Unix Process ID - SPID
  Tracing Concurrent Processes
  Recommended Concurrent Processing Resources
References
APPLIES TO:

Oracle Concurrent Processing - Version 11.5.10.2 to 12.2 [Release 11.5 to 12.2]
Information in this document applies to any platform.
PURPOSE

This document is reference document for Document 1411723.1 the EBS Concurrent Processing Analyzer.

The details in this document provides advanced sql query statements allowing select date ranges or other sql queries for monitoring Concurrent Processing.  The scripts are useful for specific Concurrent Processing (monitoring / problem isolation) needs as referenced below.

NOTE: Modification of the scripts for your use made at your own risk.  Please feel free modify the scripts for use as needed as they are not controlled by Oracle Support.


TROUBLESHOOTING STEPS

NOTE: Example execution for the scripts referenced below:

SQL>sqlplus apps/<apps_password> @<script.sql>





Script Provides Daily Concurrent Request Counts Completed by Hour

REM #########################################################################
REM ## Purpose: Script provides daily Concurrent Requests counts completed by hour
REM ## Filename: daily_request_count_completed_hourly.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @daily_request_count_completed_hourly.sql
REM ## Output: ConcurrentRequestCount.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column st_dt format date

spool ConcurrentRequestCount.lst
select
    p.user_concurrent_program_name Program_name,
    to_char(r.actual_start_date,'DD-MON-YYYY HH24') Date_of_exec,
    count(r.request_id)     Executions,
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id = '&appl_id'
    and r.status_code = 'C'
    and r.phase_code = 'C'
   and to_char(r.actual_start_date,'DD-MON-YYYY') between '&begin_date' and '&end_date'
group by p.user_concurrent_program_name,to_char(r.actual_start_date,'DD-MON-YYYY HH24')
order by to_char(r.actual_start_date,'DD-MON-YYYY HH24') asc
/
spool off

Click To Download dlyrequctcomped.sql



Script Provides the Concurrent Requests Counts, Time, and Range

REM #########################################################################
REM ## Purpose: Script provides the Concurrent Requests counts, Time, and Range
REM ## Filename: Node_Request_Count_TimeRange.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @Node_Request_Count_TimeRange.sql
REM ## Output: Node_Request_Count_TimeRange.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
break on Date_of_exec
compute sum of Executions on Date_of_exec

column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column Manager_name format a10
column Node_Name   format a11
spool NodeConcurrentRequestCountTimeRange.lst
select
    p.user_concurrent_program_name Program_name,
    q.concurrent_queue_name Manager_name,
    q.NODE_NAME             Node_Name,
    to_char(r.actual_start_date,'DD-MON-YYYY HH24') Date_of_exec,
    count(r.request_id)     Executions,
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id = '&appl_id'
    and actual_start_date between to_date('&&begin_date','DD-MON-YYYY HH24') and to_date('&&end_date','DD-MON-YYYY HH24')
   and r.status_code = 'C'
    and r.phase_code in ('C')
group by p.user_concurrent_program_name,to_char(r.actual_start_date,'DD-MON-YYYY HH24'),q.concurrent_queue_name,q.node_name
order by to_char(r.actual_start_date,'DD-MON-YYYY HH24') asc
/
spool off

Click To Download reqcntimerange.sql



Script Provides the Count by Name and Date

REM #########################################################################
REM ## Purpose: Script provides the count by Name and Date
REM ## Filename: program_queue_count_byname_date.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @program_queue_count_byname_date.sql
REM ## Output: program_queue_count_byname_date.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
spool program_queue_count_byname_date.lst
select  n.user_concurrent_program_name Program_name,
        q.concurrent_queue_name,
        count(*) cnt,
        sum(r.actual_completion_date - r.actual_start_date) * 24 elapsed,
        avg(r.actual_completion_date - r.actual_start_date) * 24 average,
        stddev(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 wstddev,
        sum(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 waited,
        avg(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 avewait
from
        apps.fnd_concurrent_requests r,
        apps.fnd_concurrent_queues q,
        apps.fnd_concurrent_processes p,
        apps.fnd_concurrent_programs_vl n
where
            n.concurrent_program_id = r.concurrent_program_id
        and n.application_id = r.program_application_id
        and r.concurrent_program_id = p.concurrent_program_id
        and r.phase_code='C'
        and r.status_code in ('C','G')
        and r.controlling_manager=p.concurrent_process_id
        and q.concurrent_queue_id=p.concurrent_queue_id
        and n.user_concurrent_program_name like '&prog_name'
        and to_char(r.actual_completion_date,'DD-MON-YYYY') between '&begin_date' and '&end_date'
group by  q.concurrent_queue_name,n.user_concurrent_program_name
order by 4;

spool off
Click To Download prgquect_namdate.sql



Script Provides the Count of Requests Completed and Canceled


REM #########################################################################
REM ## Purpose: Script provides the count of requests completed and canceled.
REM ## Filename: request_count_completedcancelled.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @request_count_completedcancelled.sql
REM ## Output: request_count_completedcancelled.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
break on report
compute sum of Executions on report
set pages 10000
set lines 180
set verify off
column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column st_dt format date

spool completedcancelledrequestcount.lst
select
    p.user_concurrent_program_name Program_name,
    to_date(r.actual_start_date,'DD-MON-YYYY') Date_of_exec,
    count(r.request_id)     Executions,
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id = '&appl_id'
    and r.status_code = 'D'
    and r.phase_code = 'C'
     and to_char(r.actual_start_date,'DD-MON-YYYY')='&begin_date'
group by p.user_concurrent_program_name,to_date(r.actual_start_date,'DD-MON-YYYY')
order by to_date(r.actual_start_date,'DD-MON-YYYY') asc
/
spool off
Click To Download reqcntcomcanc.sql



Script Provides the Count of Requests Completed with Error

REM #########################################################################
REM ## Purpose: Script provides the count of requests completed with error.
REM ## Filename: request_count_completederror.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @request_count_completederror.sql
REM ## Output: completederrorRequestCount.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
break on report
compute sum of Executions on report
set pages 10000
set lines 180
set verify off
column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column st_dt format date

spool completederrorRequestCount.lst
select
    p.user_concurrent_program_name Program_name,
    to_date(r.actual_start_date,'DD-MON-YYYY') Date_of_exec,
    count(r.request_id)     Executions,
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id = '&appl_id'
    and r.status_code = 'E'
    and r.phase_code = 'C'
     and to_char(r.actual_start_date,'DD-MON-YYYY')='&begin_date'
group by p.user_concurrent_program_name,to_date(r.actual_start_date,'DD-MON-YYYY')
order by to_date(r.actual_start_date,'DD-MON-YYYY') asc
/
spool off

Click To Download reqctcomperror.sql



Script Provides the Count of Requests Pending and Scheduled

break on report
compute sum of Executions on report
set pages 10000
set lines 180
set verify off
column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column st_dt format date

spool pendingscheduledRequestCount.lst
select
    p.user_concurrent_program_name Program_name
    to_date(r.actual_start_date,'DD-MON-YYYY') Date_of_exec
    count(r.request_id)     Executions
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
      p.application_id = r.program_application_id
and
      r.phase_code = 'P'
/
spool off

Click To Download reqctpenschd.sql



Script Provides the Count of Requests Terminated by Date

REM #########################################################################
REM ## Purpose: Script provides the count of requests terminated by date.
REM ## Filename: running_terminated_requests_bydate.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @running_terminated_requests_bydate.sql
REM ## Output: runningterminatedRequestCount.lst
REM ##
REM #########################################################################
break on report
compute sum of Executions on report
set pages 10000
set lines 180
set verify off
column program_name format a50
column request_id format 99999999 heading 'REQUEST'
column st_dt format date

spool runningterminatedRequestCount.lst
select
    p.user_concurrent_program_name Program_name,
    to_date(r.actual_start_date,'DD-MON-YYYY') Date_of_exec,
    count(r.request_id)     Executions,
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) Max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id = '&appl_id'
    and r.status_code = 'T'
    and r.phase_code = 'R'
     and to_char(r.actual_start_date,'DD-MON-YYYY')='&begin_date'
group by p.user_concurrent_program_name,to_date(r.actual_start_date,'DD-MON-YYYY')
order by to_date(r.actual_start_date,'DD-MON-YYYY') asc
/
spool off

Click To Download run_term_reqbydt.sql




Script Provides the Count of Requests by Date

REM #########################################################################
REM ## Purpose: Script provides the count of requests by date.
REM ## Filename: startdate_count_bydate.sql
REM ## Certified for Application releases 11.5 through 12.x
REM ## Document: <nnnnnn.1>
REM ## Usage: sqlplus apps/<appspwd> @startdate_count_bydate.sql
REM ## Output: startdate_count_bydate.lst
REM ##
REM #########################################################################
set pages 10000
set lines 180
set verify off
spool startdate_count_bydate.lst
select to_char(actual_start_date,'DD-MON-YYYY HH24'),count(request_id)
from apps.fnd_concurrent_requests
where actual_start_date between to_date('&&begin_date','DD-MON-YYYY HH24')
and to_date('&&end_date','DD-MON-YYYY HH24') and status_code = 'C'
and phase_code in ('C')
group by  to_char(actual_start_date,'DD-MON-YYYY HH24')
/
spool off
Click To Download strtdat_ct_bydat.sql



Quick Sql Statement to check Average Monthly Requests

set head off
select avg(count(1)) from apps.fnd_concurrent_requests
where trunc(actual_start_date) >trunc(sysdate -30) group by trunc(actual_start_date);

Click To Download avg_mon_reqs.sql



Script Identifying Concurrent Managers Used and Compare

REM cmhist.sql
REM Use this report to tell which concurrent managers are actually being
REM used in an environment and compare to the concurrent managers that
REM are allocated processes at startup.  This report only reviews completed
REM normal or completed warning concurrent requests.
REM
REM Deactivate any managers that are not used.
REM
REM It makes no sense to run this request with a date range greater than
REM what is contained in the fnd_concurrent_requests table.  Therefore,
REM base dates on the purge frequency.
REM
set verify off
set feedback off
set pagesize 59
set linesize 180
set newpage 02
set recsep off
break on report
compute sum of cnt on report
compute sum of elapsed on report
compute sum of waited on report
rem  column today new_value _date noprint;
rem  select to_char(SYSDATE,'DD-MON-YY') today from dual;
rem  ttitle "Concurrent Manager Request Summary  by Manager from: &&begin_date to &&end_date" skip 2;
column waited format 99999999.99 heading 'WAITED|HOURS';
column wstddev format 99999999.99 heading 'WAITED|STDDEV';
column avewait format 9999.99 heading 'AVG.|WAIT';
column concurrent_queue_name format a30 wrap;
column cnt format 999,999 heading 'COUNT';
column elapsed format 99999.99 heading 'TOTAL|HOURS';
column average format 9999.99 heading 'AVG.|HOURS';
set feedback off
select  q.concurrent_queue_name,
        count(*) cnt,
        sum(r.actual_completion_date - r.actual_start_date) * 24 elapsed,
        avg(r.actual_completion_date - r.actual_start_date) * 24 average,
        stddev(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 wstddev,
        sum(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 waited,
        avg(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 avewait
from    apps.fnd_concurrent_programs p,
        apps.fnd_concurrent_requests r,
        apps.fnd_concurrent_queues q,
        apps.fnd_concurrent_processes p
where   r.program_application_id = p.application_id
        and r.concurrent_program_id = p.concurrent_program_id
        and r.phase_code='C' -- completed
        and r.status_code in ('C','G')  -- completed normal or with warning
        and r.controlling_manager=p.concurrent_process_id
        and q.concurrent_queue_id=p.concurrent_queue_id
        and r.concurrent_program_id=p.concurrent_program_id
        and actual_start_date between to_date('&&begin_date') and to_date('&&end_date')
group by  q.concurrent_queue_name
order by 4;
set feedback on;
clear breaks

Click To Download cm_useagedtange.sql



Elapsed Time History for All Requests Run for a Given Time Period

REM
REM
REM Elapsed time history for all requests run for a given time period.
REM
REM To help assign requests that always run fast to one queue, and slow requests to a slow queue
REM
REM
rem set timing off
rem set heading off
set verify off
rem set show off
rem set echo off
set feedback off
set pagesize 500
set linesize 250
column elapsed format 999.99 heading 'TOTAL|HOURS';
column average format 99.99 heading 'AVG|HOURS';
column max     format 99.99 heading 'MAX|HOURS';
column min     format 99.99 heading 'MIN|HOURS';
column waited  format 99999.99 heading '#WAITED|HOURS';
column avewait format 9999.99 heading 'AVG|WAIT';
column program format a20 heading 'PROGRAM';
column description format a55;
column cnt format 999,999 heading '#TIMES|RUN';
column app format a6 heading 'APP';
break on report
compute sum of cnt on report
compute sum of elapsed on report
compute sum of waited on report
column stddev format 999.99 heading 'RUN|STDDEV';
column wstddev format 999.99 heading 'WAIT|STDDEV'
column type format a15 heading 'TYPE'
column priority format 999 heading 'PRI'
column concurrent_queue_name format a14 heading 'Concurrent Mgr' trunc
select
   f.application_short_name app,
   substr(p.user_concurrent_program_name,1,55) description,
   substr(p.concurrent_program_name,1,20) program,
   r.priority,
   count(*) cnt,
   sum(actual_completion_date - actual_start_date) * 24 elapsed,
   avg(actual_completion_date - actual_start_date) * 24 average,
   max(actual_completion_date - actual_start_date) * 24 max,
   min(actual_completion_date - actual_start_date) * 24 min,
   stddev(actual_completion_date - actual_start_date) * 24 stddev,
   stddev(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 wstddev,
   sum(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 waited,
   avg(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 avewait,
   c.request_class_name type
from apps.fnd_concurrent_request_class c,
     apps.fnd_application f,
     apps.fnd_concurrent_programs_vl p,
     apps.fnd_concurrent_requests r
where r.program_application_id = p.application_id
   and r.concurrent_program_id = p.concurrent_program_id
   and r.status_code in ('C','G') -- maybe 'E' also
   and r.phase_code = 'C'
   and actual_completion_date between to_date('&&begindate') and to_date('$$enddate')
   and p.application_id = f.application_id
   and r.program_application_id = f.application_id
   and r.request_class_application_id = c.application_id(+)
   and r.concurrent_request_class_id = c.request_class_id(+)
group by
   c.request_class_name,
   f.application_short_name,
   p.concurrent_program_name,
   p.user_concurrent_program_name,
   r.priority
/
clear breaks

Click To Download reqelaptimhist.sql



Select for Providing Frequency/Volume Analysis Program Name, Queue Name, and Count by Program Name and Date Range

REM     select statement to pull Program Name, Queue Name, and Count by program name and date range for frequency/volume analysis
REM

select  n.user_concurrent_program_name Program_name,
        q.concurrent_queue_name,
        count(*) cnt,
        sum(r.actual_completion_date - r.actual_start_date) * 24 elapsed,
        avg(r.actual_completion_date - r.actual_start_date) * 24 average,
        stddev(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 wstddev,
        sum(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 waited,
        avg(actual_start_date - greatest(r.requested_start_date,r.request_date)) * 24 avewait
from
        apps.fnd_concurrent_requests r,
        apps.fnd_concurrent_queues q,
        apps.fnd_concurrent_processes p,
        apps.fnd_concurrent_programs_vl n
where
            n.concurrent_program_id = r.concurrent_program_id
        and n.application_id = r.program_application_id
        and r.concurrent_program_id = p.concurrent_program_id
        and r.phase_code='C' -- completed
        and r.status_code in ('C','G')  -- completed normal or with warning
        and r.controlling_manager=p.concurrent_process_id
        and q.concurrent_queue_id=p.concurrent_queue_id
        and n.user_concurrent_program_name like '&1'
        and to_char(r.actual_completion_date,'DD-MON-YYYY') between '&2' and '&3'
group by  q.concurrent_queue_name,n.user_concurrent_program_name
order by 4;
set feedback on;
clear breaks

Click To Download reqnamdatprog.sql



Request Volume Per Day Select which can be Modified with Additions to the Where Clause

REM Request Volume Per Day Select which can be modified with additions to the where clause
REM

set pages 1000
set lines 180
select trunc(actual_start_date),count(*)
from apps.fnd_concurrent_requests
where trunc(Actual_start_date) >trunc(sysdate -61)
group by trunc(actual_start_date);
Click To Download req_vol_perday.sql



Select Providing the Volume of Concurrent Requests Per Node

REM Concurrent Requests per node select statement
REM

set head off
Break on trunc(actual_start_date)
compute SUM of count(1) on trunc(actual_start_date);
select count(1),trunc(actual_start_date) ,logfile_node_name from apps.fnd_concurrent_requests
where trunc(actual_start_date) >trunc(sysdate -30) group by trunc(actual_start_date),logfile_node_name order by trunc(actual_start_date),count(1);
Click To Download req_by_node.sql



Select reflecting All Requests with Run Times > 30 Minutes During Peak Load in the Past Month by Application_Id

rem Script: Requests_Over_30Min_by_App_Id.sql
rem All requests with run times > 30 minutes during peak load in the past month by Application_Id.

undefine start_date
undefine end_date

set pages 10000
set verify off
column request_id format 99999999 heading 'REQUEST'
column user_name format a17
column phase format a10
column status format a12
column start_date format a5
column completion_date format a5 heading 'END'
column avg_run_time format 9999 heading 'AVG TIME'
column min_run_time format 9999 heading 'MIN TIME'
column max_run_time format 9999 heading 'MAX TIME'
column program_name format a50

select
    p.user_concurrent_program_name program_name,
    count(r.request_id),
    avg((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) avg_run_time,
    min((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) min_run_time,
    max((nvl(r.actual_completion_date,sysdate) - r.actual_start_date) * 24 * 60) max_run_time
from
    apps.fnd_concurrent_requests r,
    apps.fnd_concurrent_processes c,
    apps.fnd_concurrent_queues q,
    apps.fnd_concurrent_programs_vl p
where
    p.concurrent_program_id = r.concurrent_program_id
    and p.application_id = r.program_application_id
    and c.concurrent_process_id = r.controlling_manager
    and q.concurrent_queue_id = c.concurrent_queue_id
    and p.application_id >= &&ApplicationId
    and r.actual_start_date >= sysdate-31
    and r.status_code = 'C'
    and r.phase_code in ('C')
    and (nvl(r.actual_completion_date,r.actual_start_date) - r.actual_start_date) * 24 * 60 > 30
    and p.user_concurrent_program_name not like 'Gather%Statistics%'
    and (
      (nvl(r.actual_completion_date,r.actual_start_date) - r.actual_start_date) * 24 > 16
      or
      (r.actual_start_date-trunc(r.actual_start_date)) * 24 between 9 and 17
      or
      (r.actual_completion_date-trunc(r.actual_completion_date)) * 24 between 9 and 17
    )
group by p.user_concurrent_program_name
/

Click To Download reqs_over_30min.sql



Select Providing Request ID's for Requests that are Currently Running

alter session set nls_date_format='dd-mon-yy hh24:mi:ss';
 SEt linesize 200
 set pagesize 2000
 col "Secondswait" format 9999 wrap heading 'SWait' print
 col "WaitEvent" format a12 wrap heading 'Waiting|On Event' print
 col "Session Wait" format a12 wrap heading 'file#|block#|id(Reason)' print
 Column Manager   Format A12 trunc heading 'Manager|Queue' print
 col "ServerClient" format a7 heading 'Server|Client' print
 col "SidSerialSQLHash"  format a10 heading 'Sid|Serial#|SQLHash' print
 col "DBPhaseStatusCODEUser" format a10 heading 'UserName|CP PhSCode|Db Status' print
 col Request_id  Format a10 heading 'RequestID|PriorityID|ParentID' print wrap
 col "RequestStartDate" Format a10 heading 'ReqStart|Minutes' print
 column concurrent_program_name format a25 heading 'CCM Short|Name' noprint
 column user_concurrent_program_name format a20 wrap heading 'Concurrent|Program Name' print
 column ARGUMENT_TEXT format a15 heading 'CCM Arguments' print
 column "SQLHASH" format 9999999999 heading 'SQL|HASH' print
 column CONCURRENT_QUEUE_ID format 99999 heading 'CCM |Queue ID' print
 column QUEUE_DESCRIPTION format a20 heading 'CCM |Queue Name' noprint

 select
 w.seconds_in_wait "Secondswait",
 w.event "waitEvent",
 w.p1||chr(10)||w.p2||chr(10)||w.p3 "Session Wait",
 p.spid||chr(10)||s.process "ServerClient",
 s.sid||chr(10)||s.serial#||chr(10)||s.sql_hash_value "SidSerialSQLHash",
 u.user_name||chr(10)||PHASE_CODE||' '||STATUS_CODE||chr(10)||s.status "DBPhaseStatusCODEUser",
 Request_id||chr(10)||priority_request_id||chr(10)||Parent_request_id "Request_id",
 concurrent_program_name,
 user_concurrent_program_name,
 requested_start_Date||chr(10)||round((sysdate- requested_start_date)*1440, 2)||'M' "RequestStartDate",
 ARGUMENT_TEXT,
 CONCURRENT_QUEUE_ID,
 QUEUE_DESCRIPTION
FROM
 FND_CONCURRENT_WORKER_REQUESTS,
 fnd_user u,
 v$session s,
 v$process p,
 v$session_wait w
WHERE
--  nvl(request_type, 'X') != 'S' and
--  (request_id = &&request_id)
(Phase_Code='R')
and hold_flag != 'Y'
and Requested_Start_Date <= SYSDATE
AND ('' IS NULL OR ('' = 'B' AND PHASE_CODE = 'R' AND STATUS_CODE IN ('I', 'Q')))
and '1' in (0,1,4)
and requested_by=u.user_id
and s.paddr=p.addr
and s.sid=w.sid
and oracle_process_id = p.spid
and oracle_session_id = s.audsid
order by requested_start_date
;
--and request_id=&&request_id;
Click To Download req_run_by_reqid.sql



Session Information Available from an Oracle Unix Process ID - SPID

REM  FILENAME spid_session_k.sql                                        
REM  DESCRIPTION                                                        
REM  Session information availabe from an Oracle unix process id - SPID  

set verify off
set echo off
set head off
set pages 1000
PROMPT Enter SPID :
ACCEPT 1
spool spid&1


PROMPT  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PROMPT  Details of SPID &1
PROMPT  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   select 'SID............ : ' || a.sid                                         || chr(10) ||
          'SERIAL#........ : ' || a.serial#                                     || chr(10) ||
          'USERNAME....... : ' || a.username                                    || chr(10) ||
          'COMMAND........ : ' || a.command                                     || chr(10) ||
          'STATUS......... : ' || a.status                                      || chr(10) ||
          'Machine........ : ' || a.machine                                     || chr(10) ||
          'Terminal....... : ' || a.terminal                                    || chr(10) ||
          'Program........ : ' || a.program                                     || chr(10) ||
          'Module........ : '  || a.module                                      || chr(10) ||
          'SQL Hash Value. : ' || a.sql_hash_value                              || chr(10) ||
          'Logon Time..... : ' || to_char(a.logon_time,'DD-Mon-YYYY HH:MI:SS')  || chr(10) ||
          'Last Call Et... : ' || a.last_call_et                                || chr(10) ||
          'Process ID..... : ' || a.process                                     || chr(10) ||
          'SPID........... : ' || b.spid
   from   v$session a, v$process b
   where  a.paddr=b.addr     and b.spid='&1';
   PROMPT
   select 'Session Waiting for event...: ' || event
   from    v$session_wait
   where   sid in(select sid from v$session a, v$process b where  a.paddr=b.addr     and b.spid='&1');
   PROMPT  SQL STATEMENT :
   PROMPT  ===============
   select sql_text
   from   v$sqltext
   where  hash_value in(select sql_hash_value from v$session a, v$process b where  a.paddr=b.addr  and b.spid='&1')
   order  by piece;


spool off
Click To Download sess_info_spid.sql



Tracing Concurrent Processes

For example the following unix process id was consuming high CPU 25807.


1. Obtain the Oracle process identifier or the Operating System process
   identifier (SPID) from v$process:


       SQL> sqlplus /nolog
       connect / as sysdba
       select pid, spid, username from v$process;


               PID    SPID   USERNAME
               ----   -----  --------
               8      25807  oracle


2. Attach to the process using ORADEBUG.


I.   Using the Oracle process identifier:


       SQL> oradebug setorapid 8

       Unix process pid: 25807, image: oracle


II.   Using the Operating System process identifier:


SQL> oradebug setospid 25807

       Oracle pid: 8, Unix process pid: 25807, image: oracle

     
3. Turn on SQL Trace for the session and the trace file name as follows:


SQL> oradebug event 10046 trace name context forever, level 12

       Statement processed.

 

SQL> oradebug tracefile_name;


 
4. Turn off the SQL trace for the session.



       SQL> oradebug event 10046 trace name context off



5. Format trace file using TKPROF.


tkprof CR2000000.trc CR0000000.out explain=apps/simple4u sort='(prsela,exeela,fchela)' print=10

      This listed the sql which was consuming CPU.

Recommended Concurrent Processing Resources

Review best practice recommendations in the Concurrent Processing - Product Information Center (PIC) Document 1304305.1
Collaborate with industry peers in the Core Concurrent Processing Community
Please see Document 1186338.1 for recorded Concurrent Processing Webcasts.