my PT notes

 13/2/2020 (for excel ctrl + a  and ctrl + insert / shift + insert)  ============  PRB0068823   (INC2913704  josh)  (INC3833475/ VVV imp INC0674838--- INC4449072 ---- prem/suraj G2CPRD)

---------

INC6017536 --- Pdb 




SELECT * FROM table(DBMS_XPLAN.DISPLAY_AWR(sql_id=>'2k8z7fpqjbvdp',format => 'ADVANCED',plan_hash_value=>1619395103));



variable x varchar2(100);

exec :x:=dbms_sqldiag.create_sql_patch(sql_id=>'2k8z7fpqjbvdp', hint_text=>'OPT_PARAM(''_optimizer_adaptive_plans'' ''FALSE'') optimizer_features_enable(''12.1.0.2'')', name=> 'SQL_Patch_adp_pln_false_ofe12102');


To check parameter was set on/OFF:

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


SELECT

a.ksppinm Param ,

b.ksppstvl SessionVal ,

c.ksppstvl InstanceVal,

a.ksppdesc Descr

FROM

x$ksppi a ,

x$ksppcv b ,

x$ksppsv c

WHERE

a.indx = b.indx AND

a.indx = c.indx AND

a.ksppinm ='_optimizer_cbqt_or_expansion'

ORDER BY

1;


PARAM

--------------------------------------------------------------------------------

SESSIONVAL

--------------------------------------------------------------------------------

INSTANCEVAL

--------------------------------------------------------------------------------

DESCR

--------------------------------------------------------------------------------

_optimizer_cbqt_or_expansion

OFF

OFF

enables cost based OR expansion


MAKANCHA-3D0CB


      BOX                           USERNAME             OS_USER              PROGRAM                        

 ------------------------------  -------------------- -------------------- ------------------------------ 

     PARTNERS\MAKANCHA-3D0CB         PERF11I              makancha             Toad.exe                       


Oracle SR Track :


SR 3-30219096131 : Program taking more time in TS3CSF after 19 C upgrade.


*********************************************************    OPT parameters 

  OPT_PARAM('_b_tree_bitmap_plans' 'false')

      OPT_PARAM('_fast_full_scan_enabled' 'false')

      OPT_PARAM('_bloom_filter_enabled' 'false')

      OPT_PARAM('_optimizer_cbqt_or_expansion' 'off')

      OPT_PARAM('_optimizer_aggr_groupby_elim' 'false')

      OPT_PARAM('_optimizer_reduce_groupby_key' 'false')

*****************************************************************  


Run this 

when we dont see plan for xplan_display_awr/Cursor :

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


SQL> set linesize 250 pagesize 0 trims on tab off long 1000000

SQL> column report format a220

SQL>

SQL> select

  2     DBMS_SQL_MONITOR.REPORT_SQL_MONITOR

  3          (sql_id=>'bu6thnpcmmvsp',report_level=>'ALL') report

  4  from dual; 

  

  

      OPT_PARAM('_b_tree_bitmap_plans' 'false')

      OPT_PARAM('_optimizer_unnest_scalar_sq' 'false')

      OPT_PARAM('_px_adaptive_dist_method' 'off')

      OPT_PARAM('_optimizer_strans_adaptive_pruning' 'false')

      OPT_PARAM('_optimizer_cbqt_or_expansion' 'off')

      OPT_PARAM('_optimizer_aggr_groupby_elim' 'false')

      OPT_PARAM('_optimizer_reduce_groupby_key' 'false')

      OPT_PARAM('_optimizer_nlj_hj_adaptive_join' 'false')

      OPT_PARAM('_fix_control' '7452863:0')

  

To monitor sql that is Running :

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

  

select sql_id,Plan_hash_value,Rows_processed,buffer_gets,Disk_reads,EXECUTIONS from gv$sqlarea where sql_id='bu6thnpcmmvsp'


SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME,

         SQL_ID,

         PLAN_HASH_VALUE,

         SUM (EXECUTIONS) EXECUTIONS,

         ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC,

         ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1)

            PIO_PER_EXEC,

         ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1)

            LIO_PER_EXEC,

         ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)

            ROWS_PER_EXEC,

         ROUND (

              (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1))

            / GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1),

                        1),

            1)

            lio_per_row,

            ROUND (

               (SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1),

               1)

         || 'ms/'

         || ROUND (

                 (SUM (ELAPSED_TIME) / 1000 / 1000)

               / GREATEST (SUM (EXECUTIONS), 1),

               2)

         || 'sec/'

         || ROUND (

                 (SUM (ELAPSED_TIME) / 1000 / 1000 / 60)

               / GREATEST (SUM (EXECUTIONS), 1),

               1)

         || 'min'

            TIME_PER_EXEC,

         MAX (sql_profile) sqlprofile

    FROM GV$SQL

   WHERE SQL_ID = '&sql_id'

GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME)

ORDER BY 1 DESC;



Test case : 5 :

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


 alter session set "_fix_control"='30998035:1','30972817:1','30222669:1','29867728:1','7452863:1';

 alter session set "_optimizer_adaptive_cursor_sharing" = FALSE

 alter session set "_optimizer_extended_cursor_sharing_rel" = NONE

 alter session set "_optimizer_use_feedback" = FALSE

 

 To test Run for simple view merge is set to false :


TS3CSF : Test case 1 :


alter session set "_simple_view_merging" = false;


alter session set "_complex_view_merging" = false;


alter session  set "_optimizer_use_feedback" = false


alter session  set "_optimizer_use_feedback" = false


alter session set  optimizer_features_enable = '12.1.0.2';


************

 

 This is basically to address 19c performance issue where most of the SQL's goes for Nested loop rather than hash join.

 

 alter session set "_fix_control"='26527656:0';

 

 /*+ opt_param('optimizer_adaptive_plans','false') optimizer_features_enable('12.1.0.2') OPT_PARAM('_px_adaptive_dist_method','off') OPT_PARAM('_optimizer_use_feedback','false') */ 

 

 /*+ NO_QUERY_TRANSFORMATION */

 

 /*+ no_parallel */

 

 /*+ opt_param('optimizer_adaptive_plans','false') optimizer_features_enable('12.1.0.2') OPT_PARAM('_px_adaptive_dist_method','off') OPT_PARAM('_optimizer_use_feedback','false') */ 

 

      OPT_PARAM('_optimizer_use_feedback' 'false')  

      OPT_PARAM('_px_adaptive_dist_method' 'off')

      OPT_PARAM('_optimizer_dsdir_usage_control' 0)

      OPT_PARAM('_optimizer_adaptive_plans' 'false')   

      OPT_PARAM('_optimizer_strans_adaptive_pruning' 'false')

      OPT_PARAM('_optimizer_gather_feedback' 'false')

  

alter session set "_fix_control"='26527656:0';


************************ To check PX realted


col PARAMETER for a40

col "DEFAULT_VALUE" for a20

col "SESSION_VALUE" for a20

col "INSTANCE_VALUE" for a20

col IS_SESSION_MODIFIABLE for a20

col IS_SYSTEM_MODIFIABLE for a20

SELECT a.ksppinm "PARAMETER", b.KSPPSTDF "DEFAULT_VALUE",

       b.ksppstvl "SESSION_VALUE", 

       c.ksppstvl "INSTANCE_VALUE",

       decode(bitand(a.ksppiflg/256,1),1,'TRUE','FALSE') "IS_SESSION_MODIFIABLE",

       decode(bitand(a.ksppiflg/65536,3),1,'IMMEDIATE',2,'DEFERRED',3,'IMMEDIATE','FALSE') "IS_SYSTEM_MODIFIABLE"

FROM   x$ksppi a,

       x$ksppcv b,

       x$ksppsv c

WHERE  a.indx = b.indx

AND    a.indx = c.indx

AND    a.ksppinm LIKE '/_in_memory_cdt' escape '/' ;

from Madan Kumar Kancharla (Cisco) to everyone:    8:34 PM

TS3CSF

PARAMETER                                DEFAULT_VALUE

---------------------------------------- --------------------

SESSION_VALUE        INSTANCE_VALUE       IS_SESSION_MODIFIABL

-------------------- -------------------- --------------------

IS_SYSTEM_MODIFIABLE

--------------------

_px_adaptive_dist_method                 TRUE

CHOOSE               CHOOSE               TRUE

IMMEDIATE 



alter session set "_fix_control"='13831671:0';

alter session set "_fix_control"='12555499:0'; 

alter session set "_fix_control"='26527656:0';


SELECT /*+ OPT_PARAM('_fix_control' '6377505:OFF 6006300:OFF') */ *

FROM   ...;



SELECT /*+ OPT_PARAM('_fix_control' '6377505:OFF') */ *

FROM   ...;


ALTER SESSION SET "_fix_control"='6377505:OFF','6006300:OFF';


ALTER SESSION SET "_fix_control"='6377505:OFF';

ALTER SESSION SET "_fix_control"='6377505:0';


-- On

ALTER SESSION SET "_fix_control"='6377505:ON';

ALTER SESSION SET "_fix_control"='6377505:1';


select * from dba_sql_profiles order by created desc --- to check when sql profile depoyed


alter session set  optimizer_features_enable = '12.1.0.2'; ********** OPTIMIZER_FEATURES_ENABLE('19.1.0')


SELECT /*+ opt_param('_optimizer_cbqt_or_expansion','off') optimizer_features_enable('12.1.0.2')*/



select /*+ opt_param('_optimizer_cbqt_or_expansion','off') optimizer_features_enable('12.1.0.2')*/ OEOLA.line_id, OEOLA.inventory_item_id, OEOLA.org_id,

        OEOLA.ship_from_org_id,

        OEOLA.order_quantity_uom, OEOLA.ordered_quantity,

        OEOLA.schedule_ship_date, OEOLA.booked_flag

 from   APPS.OE_ORDER_LINES_ALL OEOLA

       ,APPS.wf_item_activity_statuses WAS

       ,APPS.wf_process_activities WPA

 where  OEOLA.ORDERED_QUANTITY <> 0

 and    OEOLA.ATO_LINE_ID = OEOLA.LINE_ID

 and    OEOLA.OPEN_FLAG = 'Y'

 and    OEOLA.schedule_ship_date is not null

 and    OEOLA.item_type_code in ( 'MODEL' , 'CLASS' )

 and    OEOLA.SHIP_FROM_ORG_ID = :organization_id

 and    WAS.ACTIVITY_STATUS IN ('ACTIVE', 'NOTIFIED')

 and    WAS.ITEM_TYPE = 'OEOL'

 and    to_number(REGEXP_REPLACE(WAS.ITEM_KEY,'[[:alpha:]]|[[:punct:]]|[[:space:]]|[[:cntrl:]]','',1,0,'i')) = OEOLA.LINE_ID

 and    REGEXP_INSTR(WAS.ITEM_KEY,'[[:alpha:]]|[[:punct:]]|[[:space:]]|[[:cntrl:]]',1,1,0,'i') = 0

 and    WAS.PROCESS_ACTIVITY = WPA.INSTANCE_ID

 and    WPA.ACTIVITY_ITEM_TYPE = WAS.ITEM_TYPE

 and    ( WPA.ACTIVITY_NAME = 'CREATE_CONFIG_ITEM_ELIGIBLE' OR ( WPA.ACTIVITY_NAME = 'BOOK_WAIT_FOR_H' AND OEOLA.SCHEDULE_STATUS_CODE = 'SCHEDULED'

 and not exists

        (select 'X'

         from   APPS.OE_ORDER_LINES_ALL OEOLD

         where  OEOLD.ato_line_id = OEOLA.ato_line_id

         and    OEOLD.item_type_code = 'CONFIG' and rownum =1 )))


http://www.bigdatalyn.com/category/#Oracle


/*+opt_param('_optimizer_skip_scan_enabled','off')*/


/*+ materialize */


/*+ gather_plan_statistics */ 


alter session set container=G2CPRD;



alter session set "_optimizer_use_feedback" = false


**********


alter session set "_simple_view_merging" = false;


You can also hint the inner query block statement with /*+ NO_MERGE */.


*************************************


use above if you want to format the date



alter session set nls_Date_format='DD-MON-YYYY HH24:MI:SS';




To get SQLT report :

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


Set trim on

Set pages 0

Set linesize 32767

Set long 1000000

Set longchunksize 1000000

spool sqlmon_active_9j4w4qhvxpsy8_cg1prd5_83886080_27feb1215.html



select dbms_sqltune.report_sql_monitor(sql_id=>'9j4w4qhvxpsy8', sql_exec_id=>344444,type=>'active', report_level=>'all') from dual;


spool OFF 


************** 

To get SQL monitor Report :

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


select round((m.last_refresh_time - m.sql_exec_start)*24*60*60,2) run_time,m.sql_exec_start,m.first_refresh_time,m.last_refresh_time,m.sql_plan_hash_value,m.sql_exec_id,m.* from gv$sql_monitor m where sql_id='2hd217yv7whaj'

order by status; 


**************************


********** Dynamic sampling :


–Session level.


ALTER SESSION SET OPTIMIZER_DYNAMIC_SAMPLING=11;


— Statement level


SELECT /*+ dynamic_sampling(emp 11) */


empno, ename, job, sal FROM emp WHERE  deptno = 30;


********


Cardinality feedback was introduced in Oracle Database 11g Release 2 and was renamed Statistics Feedback in Oracle Database 12c. 


The purpose of this feature is to automatically improve plans for queries that are executed repeatedly, for which the optimizer does not estimate cardinalities in the plan properly. 


The optimizer may misestimate cardinalities for a variety of reasons, such as missing or inaccurate statistics, or complex predicates. Whatever the reason for the misestimate, statistics feedback may be able to help.


During the first execution of a SQL statement, an execution plan is generated as usual. 


During optimization, 

certain types of estimates that are known to be of low quality 

(for example, estimates for tables which lack statistics or tables with complex predicates) 

are noted, and monitoring is enabled for the cursor that is produced. 


If statistics feedback monitoring is enabled for a cursor, then at the end of execution, some of the statistics estimates in the plan are compared to the actual statistics seen during execution. 


If some of these estimates are found to differ significantly from the actual statistics, the correct estimates are stored for later use. 


The next time the query is executed, it will be optimized again, and this time the optimizer uses the corrected estimates in place of its usual estimates.



The improved estimates used by cardinality feedback are not persisted. 

For this reason, it’s always preferable to use other techniques to get cardinality estimates right the first time every time, 

e.g. extended statistics, dynamic sampling, or SQL profiles. 


But for cases where these techniques do not apply, cardinality feedback can provide some relief.


Query to check How 5 table was analyzed :

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


SELECT DT.OWNER,

       DT.TABLE_NAME,

       ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) PERCENTAGE

FROM   dba_tables dt, ALL_TAB_MODIFICATIONS atm

WHERE      DT.OWNER = ATM.TABLE_OWNER

       AND DT.TABLE_NAME = ATM.TABLE_NAME

       AND NUM_ROWS > 0

       -- AND ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) >= 10

       AND OWNER NOT IN ('SYS','SYSTEM','DBSNMP','OSMMON','PERFSTAT')

       AND dt.table_name like '%OE_ORDER_LINES_ALL%'

ORDER BY 3 desc;



 De-Fragmentation

++++++++++++++++++++++++


*There are many methods.


Option 1: Shrink command


alter table  enable row movement;

/*

Using the enable row movement clause can reduce the clustering_factor for a primary access index, causing excessive I/O.  Oracle introduced the sorted gash cluster as a way to keep an index in-order with the table rows, a technique that greatly reduces I/O for common queries. 

Beware that using "enable row movement" can cause Oracle to move rows to discontinuous data blocks, causing a performance problem.  Remember, the physical placement of rows on data blocks can still make a huge difference in query performance. 

*/


alter table  shrink space compact;

alter table  shrink space cascade;


http://www.dba-oracle.com/t_enable_row_movement.htm


Option 2: Table move


Alter table move - The alter table xxx move command moves rows down into un-used space and adjusts the HWM but does not adjust the segments extents, and the table size remains the same.  The alter table move syntax also preserves the index and constraint definitions.


ALTER TABLE <table_name>  MOVE;


Option 3: EXPORT / IMPORT


** EXPORT

** DROP ALL RESPECTIVE OBJECTS

** IMPORT FROM EXPORT BACKUP



Option 4: EXPORT / IMPORT WITH TABLE_EXISTS_ACTION=REPLACE


** EXPORT

** IMPORT USING TABLE_EXISTS_ACTION=REPLACE


Query to get SQL Monitor Report :

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


Set trim on

Set pages 0

Set linesize 32767

Set long 1000000

Set longchunksize 1000000

spool sqlmon_active_b93d7617bt304_cg1prd5_83886080_17jun1404.html



select dbms_sqltune.report_sql_monitor(sql_id=>'b93d7617bt304', type=>'active', report_level=>'all',sql_exec_id=>83886102) from dual;


spool OFF


to connect to CDB Database :

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


c_perfusr

zg2cprd#123#


/*+  opt_param('_optimizer_mjc_enabled','false') opt_param('_optimizer_cartesian_enabled','false')*/ *********** to avoid merge join.


/*+ opt_param('_optimizer_use_feedback' 'false') */ *******


***** For upgrade 19 C issue learnings:


alter session set  optimizer_features_enable = '12.1.0.2';


Original query 


see o/p -=-- 3sec


alter session set  optimizer_features_enable = '19.1.0';


Original query 


see o/p ---- taking 


ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;


ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;



alter session set "_optimizer_mjc_enabled"=false;


alter session set "_optimizer_cartesian_enabled"=false;


alter session set "_optimizer_use_feedback"=false;


ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;


anshukum@cisco.com / c1sc0P3rf ==== 


oracle cred


INC7161849/INC7269527 ****** cg1 merge query ********** fts and read by other session and remove to_char function


To drop the SQL profile :

++++++++++++++++++++++++


BEGIN

DBMS_SQLTUNE.DROP_SQL_PROFILE (

name => 'PROFILE_gvpnmykf1ngr6'

);

END;



Manage SQL Profile in Oracle Database

SQL Profile is used by Optimizer for use more efficient execution plan for the SQL Query to make in accepted State. It is found in DBA_SQL_PROFILES view. It used to choose better plan by optimizer if the SQL profile plan is having low cost then optimizer use it.


Check the SQL Profile in the Database.


COLUMN category FORMAT a10

COLUMN sql_text FORMAT a20

SELECT NAME,type, SQL_TEXT, CATEGORY, STATUS FROM DBA_SQL_PROFILES;


Check the SQL Profile internal hint information


SELECT

a.name

,b.comp_data

FROM dba_sql_profiles a

,dbmshsxp_sql_profile_attr b

WHERE a.name = b.profile_name;


Create the SQL Profiles

Two ways:

1. Creating the SQL Profiles while running the manual SQL tuning task

For manually creating with SQL Tuning task follows the link:

SQL Tuning Advisory


2. Automatic SQL Tuning job runs on a daily basis (in Oracle Database 11g or higher).

Check SQL profiles that have automatically been created having the value “AUTO” in the TYPE column of the DBA_SQL_PROFILES views


--Check

select name, type, status, sql_text from dba_sql_profiles;


-- Enable

exec DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER(

parameter => 'ACCEPT_SQL_PROFILES', value => 'TRUE');


-- Disable

DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER(

parameter => 'ACCEPT_SQL_PROFILES', value => 'FALSE');


Disable the SQL Profiles


BEGIN

DBMS_SQLTUNE.ALTER_SQL_PROFILE(

name => 'SYS_SQLPROF_789tfag56hjli0004',

attribute_name => 'STATUS',

value => 'DISABLED');

END;

/


Drop the SQL Profile


exec dbms_sqltune.drop_sql_profile('SYS_SQLPROF_9824ryfg6f7d78653');


Drop all profiles in a database, using PL/SQL block:


declare

cursor c1 is select name from dba_sql_profiles;

begin

for r1 in c1 loop

dbms_sqltune.drop_sql_profile(r1.name);

end loop;

end;

/Manage SQL Profile in Oracle Database

SQL Profile is used by Optimizer for use more efficient execution plan for the SQL Query to make in accepted State. It is found in DBA_SQL_PROFILES view. It used to choose better plan by optimizer if the SQL profile plan is having low cost then optimizer use it.


Check the SQL Profile in the Database.


COLUMN category FORMAT a10

COLUMN sql_text FORMAT a20

SELECT NAME,type, SQL_TEXT, CATEGORY, STATUS FROM DBA_SQL_PROFILES;


Check the SQL Profile internal hint information


SELECT

a.name

,b.comp_data

FROM dba_sql_profiles a

,dbmshsxp_sql_profile_attr b

WHERE a.name = b.profile_name;


Create the SQL Profiles

Two ways:

1. Creating the SQL Profiles while running the manual SQL tuning task

For manually creating with SQL Tuning task follows the link:

SQL Tuning Advisory


2. Automatic SQL Tuning job runs on a daily basis (in Oracle Database 11g or higher).

Check SQL profiles that have automatically been created having the value “AUTO” in the TYPE column of the DBA_SQL_PROFILES views


--Check

select name, type, status, sql_text from dba_sql_profiles;


-- Enable

exec DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER(

parameter => 'ACCEPT_SQL_PROFILES', value => 'TRUE');


-- Disable

DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER(

parameter => 'ACCEPT_SQL_PROFILES', value => 'FALSE');


Disable the SQL Profiles


BEGIN

DBMS_SQLTUNE.ALTER_SQL_PROFILE(

name => 'SYS_SQLPROF_789tfag56hjli0004',

attribute_name => 'STATUS',

value => 'DISABLED');

END;

/


Drop the SQL Profile


exec dbms_sqltune.drop_sql_profile('SYS_SQLPROF_9824ryfg6f7d78653');


Drop all profiles in a database, using PL/SQL block:


declare

cursor c1 is select name from dba_sql_profiles;

begin

for r1 in c1 loop

dbms_sqltune.drop_sql_profile(r1.name);

end loop;

end;

/


***********


Hi All,


I have listed below a cool technique and effective mechanism to reduce the LOG FILE SYNC waits in 19c – Using this workaround helped and we were able to reduce LFS waits by more than 80% …


Recently while looking into a system (was running on 19.3.0.0.0 standalone) where ‘log file sync’ was bugging the database, and after we tried all other possible solutions, we thought to increase the priority of the LGWR background process to see if that helps.


Increasing the LGWR priority is putting the LGWR process in the Round-Robin (SCHED_RR) class. You can increase process’s priority both using OS (renice, nice commands) or Database methods, but this post is about setting the priority using ‘_high_priority_process’ an undocumented/hidden parameter that prioritizes your database managed processes.


I am using Oracle 19.3 for the test where the LGWR is not by default comes with any priority in the DB, starting from 21.3.0.0.0 LGWR process is part of _high_priority_processes group along with VKTM & LMS* processes.

Note: This being a hidden/undocumented parameter I advise to consult with Oracle support before going and changing the parameter value. Try other possible ways to reduce log file sync, before jumping into this crude method of prioritizing LGWR over others.


[oracle@oracleontario ~]$ !sql

sqlplus / as sysdba


SQL*Plus: Release 19.0.0.0.0 - Production on Sun Apr 10 03:36:06 2022

Version 19.3.0.0.0


Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.3.0.0.0


SQL> @hidden


Enter value for param: high_prio

old   5:    and a.ksppinm like '%&param%'

new   5:    and a.ksppinm like '%priority_processes%'


Parameter                                     Session Value             Instance Value            descr

--------------------------------------------- ------------------------- ------------------------- ------------------------------------------------------------

_highest_priority_processes                   VKTM                      VKTM                      Highest Priority Process Name Mask

_high_priority_processes                      LMS*|VKTM                 LMS*|VKTM                 High Priority Process Name Mask 

And by default in Oracle version 19.3.0.0 the parameter is set to prioritize VKTM (Virtual keeper of time) and LMS (Lock Manager, a RAC process). Let me check VKTM’s current priority class, and it is set to RR class (SCHED_RR scheduling class) for the process as its defined via _high_priority_processes parameter.


[oracle@oracleontario ~]$ ps -eo pid,class,pri,nice,time,args |grep vktm

23871 RR   41   - 00:00:53 ora_vktm_dixitdb

About the LGWR process, and it is set to TS (SCHED_OTHER) class and it has no priority class attached to it.


[oracle@oracleontario ~]$ ps -eo pid,class,pri,nice,time,args |grep ora_lg*

23990 TS   19   0 00:00:07 ora_lgwr_dixitdb

Let’s change the priority and reboot the database to persistent the change!



SQL> alter system set "_high_priority_processes"='LMS*|VKTM|LGWR' scope=spfile;


System altered.


SQL> shut immediate

Database closed.

Database dismounted.

ORACLE instance shut down.


SQL> startup

ORACLE instance started.


Total System Global Area 1593831936 bytes

Fixed Size                  8897024 bytes

Variable Size            1107296256 bytes

Database Buffers          469762048 bytes

Redo Buffers                7876608 bytes

Database mounted.

Database opened.


SQL> @hidden

Enter value for param: high_priority_processes

old   5:    and a.ksppinm like '%&param%'

new   5:    and a.ksppinm like '%high_priority_processes%'


Parameter                                     Session Value             Instance Value            descr

--------------------------------------------- ------------------------- ------------------------- ------------------------------------------------------------

_high_priority_processes                      LMS*|VKTM|LGWR            LMS*|VKTM|LGWR            High Priority Process Name Mask

At the same time I can see the same was logged into the Alert log file.


2022-04-10T03:54:31.488732-04:00

LGWR started with pid=8, OS id=26058 at elevated (RT) priority

So, we have reniced the priority of LGWR on the system, I mean the higher value of priority actually makes the process lower priority; it means the process demands fewer system resources (and therefore is a “nicer” process). Now lets check the scheduling class of the process at the OS, it should be now changed to RR from TS.


SQL> !ps -eo pid,class,pri,nice,time,args |grep ora_lm*

26058 RR   41   - 00:00:00 ora_lgwr_dixitdb

Let me check at the OS Level what has changed now.



[oracle@oracleontario 26058]$ pwd

/proc/26058

[oracle@oracleontario 26058]$ more sched

ora_lgwr_dixitd (26058, #threads: 1)

-------------------------------------------------------------------

se.exec_start                                :      26820431.663015

se.vruntime                                  :            -2.963799

se.sum_exec_runtime                          :          1858.211503

se.nr_migrations                             :                    0

nr_switches                                  :                 4038

nr_voluntary_switches                        :                 4023

nr_involuntary_switches                      :                   15

se.load.weight                               :                 1024

policy                                       :                    2      -----> Policy, the 0-99 are real-time priorities

prio                                         :                   98

clock-delta                                  :                   59

mm->numa_scan_seq                            :                    0

numa_migrations, 0

numa_faults_memory, 0, 0, 1, 0, -1

numa_faults_memory, 1, 0, 0, 0, -1


 

-- output from top utility

top - 05:09:14 up  7:32,  3 users,  load average: 0.14, 0.10, 0.11

Tasks:   2 total,   0 running,   2 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

GiB Mem :      4.3 total,      0.0 free,      1.1 used,      3.1 buff/cache

GiB Swap:      3.9 total,      3.9 free,      0.0 used.      2.1 avail Mem


   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND

26027 oracle    -2   0 2016104  20096  17064 S  1.7  0.4   1:28.22 ora_vktm_dixitdb      ---> Look at the PR (priority) column with value -2 (higher pri)

26058 oracle    -2   0 2017136  30360  26768 S  0.0  0.7   0:01.86 ora_lgwr_dixitdb      ---> Look at the PR (priority) column with value -2 (higher pri)

So, when nothing was working for us, this workaround helped and we were able to reduce LFS waits by more than 80% …





***************


IA0006051/INC7297766 M-Job Partner channels Revenue posting job on DB:PDBPROD perf analysisIA0006051/INC7297766 M-Job Partner channels Revenue posting job on DB:PDBPROD perf analysis


Query to check parallel degrade :


SELECT s.sql_id,

s.osuser,

(req_degree - degree) parallel_degradation,

ps.*

FROM gv$session s, gv$PX_SESSION ps

WHERE 1=1

--and osuser IN ('nboobala', 'sunaqvi', 'ramknair')

AND status = 'ACTIVE'

AND s.saddr = ps.saddr

ORDER BY qcsid;


https://dba.cisco.com/dba-portal/tools/session-details/ ****** To check session details from db portal



Incident INC7329407 is assigned to group DBA-Oracle 

Incident INC7329407 has been assigned to group DBA-Oracle

 

Caller: Sriganesh Palani (sripalan)

Service Offering:  Oracle Database

Summary: Unable to access SVSTST instance

Severity: 3 - Low

Priority: 5 - Standard


*********** Query to check Configurations od Database


select distinct name,value from gv$parameter where name like 'parallel_max_servers'

union

select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'sga_target'

union

select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'pga_aggregate_target'

union

select distinct name,value from gv$parameter where name like 'db_file_multiblock_read_count'

union

select distinct name,value from gv$parameter where name like 'undo_retention'

union

select distinct name,value from gv$parameter where name = 'parallel_threads_per_cpu'

union

select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'db_cache_size'

union

select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'sga_max_size'

union

select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'shared_pool_size'


************************

Hi Team,


Oracle Team suggested to drop and create the SQL Profile.

Please work on the action item shared by Oracle team in DV1CG1.


To implement the solution, please execute the following steps:


0. Please implement this action plan in a TEST instance FIRST.


1. Use the script coe_xfr_sql_profile.sql provided in Note 215187.1 :SQLTXPLAIN.SQL - Enhanced Explain Plan and related diagnostic info for one SQL statement


a. Uncompress sqlt.zip


b. Look for coe_xfr_sql_profile.sql under /<directory where you unzipped sqlt.zip file>/utl/coe_xfr_sql_profile.sql


NOTE:

This script will generate another that contains the commands to create a manual custom SQL Profile out of a known plan from memory or AWR.


REM EXECUTION

REM 1. Navigate to directory where this script resides.

REM 2. Start SQL*Plus connecting as SYSDBA.

REM 3. Execute script coe_xfr_sql_profile.sql passing SQL_ID and

REM PLAN_HASH_VALUE (parameters can be passed inline or until requested)

REM

REM EXAMPLE

REM # cd sqlt/utl

REM # sqlplus system

REM SQL> start coe_xfr_sql_profile.sql [SQL_ID] [PLAN_HASH_VALUE];

REM SQL> start coe_xfr_sql_profile.sql 5pb8pd95rynrs 1464560987;



c. The script will require the sql id and the hash value for the query with the problem. These values can be obtained from the trace file.

Example:

sqlid='1wmm1trqkzhzq'


hv=3979332550


2. This script will generate a profile for that statement


3. Drop the sql profile


Example:


BEGIN

DBMS_SQLTUNE.DROP_SQL_PROFILE(name => '<my sql profile name>');

END;

/


4. Execute the coe_xfr_sql_profile.sql script generated to recreate the sql profile


Regards,

Sreedevi

****************************************


IncidentINC7263796 ::::::  XXSSOT.SHR_EMP_ASSIGNMENTS_MV


Schema : XXSSOT

DB : ESALESPD


INC7190068 *** Cg1 *** suraj


Re: INC7133477 - GCDPRD - Materialized view is failing since 22nd Dec 2021 :  INC7173939 ::::::  


https://dba.cisco.com/dba-portal/tools/dbts


https://dba.cisco.com/dbstatus/login.do



https://dba.cisco.com/dba-portal/dashboard **** Dash board


http://www.nazmulhuda.info/fix-unusable-index ==== to make index rebuild or unusable.


***** For upgrade 19 C issue learnings:


alter session set  optimizer_features_enable = '12.1.0.2';


Original query 


see o/p -=-- 3sec


alter session set  optimizer_features_enable = '19.1.0';


Original query 


see o/p ---- taking 


ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;


https://dba.cisco.com/dba-portal/tools/session-details/CSFPRD


Approch one :


For sql id art0f01ftyq9b, we have seen sql performance has degraded after the upgrade.

So, we have tested the query by setting the optimizer_features_enable = '12.1.0.2' and the query is getting complete within few secs as before.

Let's apply a sql patch as below :

SQL> connect / as sysdba

SQL> variable x varchar2(100);

SQL> exec :x:=dbms_sqldiag.create_sql_patch(sql_id=>'art0f01ftyq9b', hint_text=>'optimizer_features_enable(''12.1.0.2'')', name=> 'SQL_Patch_12.1.0.2_art0f01ftyq9b');


to drop sql patch :

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


BEGIN

DBMS_SQLDIAG.drop_sql_patch(name => 'SQL_Patch_12.1.0.2_4hm4452dujza2');

END;

/


How to Create a SQL Patch to add Hints to Application SQL Statements (Doc ID 1931944.1)


/*+ OPTIMIZER_FEATURES_ENABLE('12.1.0.2') DB_VERSION('12.1.0.2') */


*****

INC7190068  **** vimp *** CG!


INC7185721_analysis === enq: TX - row lock contention


High Enq: TM - Contention Wait Events When Using Insert APPEND (Doc ID 2247733.1)


Resolving Issues Where Lock Contention for 'enq: TM - contention' Wait Event (TM Enqueue Contention) Occurs During ANALYZE INDEX VALIDATE STRUCTURE (Doc ID 1476083.1)


Reducing Number of Waits:


There is no actual solution for this issue other than to run the ANALYZE INDEX command during a maintenance window or quiet time; "ONLINE" option for the ANALYZE INDEX VALIDATE STRUCTURE command can be used as workaround. 

Or, You will simply need to avoid the contention by scheduling the command when there is no contention likely.


SYMPTOMS

High waits on "enq: TM - contention" when using INSERT APPEND or INSERT APPEND_VALUES:

Top 10 Foreground Events by Total Wait Time


Event Waits Total Wait Time (sec) Wait Avg(ms) % DB time Wait Class

DB CPU   4479.1   62.4

enq: TM - contention 118 1693.5 14351.89 23.6 Application



CHANGES

 


CAUSE

 

Insert append needs to require a lock at object level.  So the first session holds TM lock in X mode to lock the object. The rest of sessions must wait until the lock is released.


SOLUTION

Avoid using insert append in busy tables


Or

Rebalance your workload to decrease the concurrency


https://dba.cisco.com/dba-portal/tools/session-details =========== for trace


Interesting GG replicat perf issue

I have updated the incident ticket with the STF >>> INC7182999.

Kindly go through it as its a good learning exercise on how to fix replicat issues and improve replicat process performance


Reference ORACLE MOS Note :

Main Note - Oracle GoldenGate - Lag, Performance, Slow and Hung Processes (Doc ID 1304557.1)


For High Undo usage for instance level :(Suraj)

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

Kindly use below query to find top SQLs with high undo usage for each instance while doing your performance analysis for your assigned DBs.


SELECT b.sql_id, a.sql_hash_value,

         a.osuser,

         a.username,

         MAX (mb_used_ublk),

         a.inst_id,

         a.program,

         a.module

    FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b

   WHERE a.snap_date_time > SYSDATE - :no_of_days AND sql_hash_value != 0 and a.sql_hash_value = b.sql_hash

   and a.inst_id= :inst_id

GROUP BY b.sql_id, a.sql_hash_value,

         a.osuser,

         a.username,

         a.inst_id,

         a.program,

         a.module

  HAVING MAX (mb_used_ublk) > 500

ORDER BY 5 DESC


**********************************************************************************************************************************


INC3035477 ***** OJVM case


 INC7133477 - GCDPRD - Materialized view is failing since 22nd Dec 2021


select flashback_on from gv$database  ******** To check flashback is on or off


*************

****************************************************************

STEPS TO TROUBLESHOOT INACTIVE SESSIONS IN THE ORACLE DATABASE 

****************************************************************


1. Check the inactive session present in database


-- Check inactive and active session count

select status, count(1) from gv$session group by status;


--Check username,programname inactive count

select username, program, count(1) from gv$session where status='INACTIVE' and username = 'CPCTADM' group by username, program;


--Find more details of inactive count

select p.username "OSUSERNAME", p.terminal,p.program,

s.username "DBUSERNAME",s.command,s.status,

s.server,s.process,s.machine,s.port,s.terminal,s.program,

s.sid,s.serial#,p.spid FROM gv$session s, gv$process p

WHERE p.addr=s.paddr and s.status='INACTIVE'

order by 1,4;


2. Inactive session is caused due to Dead Connection or IDLE Connection


DEAD Connection is handle by SQLNET.ORA file by configuring parameter SQLNET.EXPIRE_TIME=minutes

Open the SQLNET ORA file and set the parameter. it is client file so set it in client side.


SQLNET.EXPIRE_TIME=60 (1 hour)


IDLE Connection is set at USER PROFILES, define profile with IDLE_TIME limit so that INACTIVE SESSION killed after the time limit reached.


-- Need to enable resource limit so it automatic terminate the session.

alter system set resource_limit=true scope=both;


--Check user which profile it uses

SELECT USERNAME, USER_ID, PROFILE FROM DBA_USERS;


--check profile setting for IDLE_TIME

select profile, limit from DBA_PROFILES where resource_name = 'IDLE_TIME';



--Alter IDLE TIME to 30 minutes after it disconnect

alter profile customers_profiles limit idle_time 30;


Note: idle_time parameter will disconnect sessions after n minutes of inactivity.


Note: We can also use Resource Manager to kill INACTIVE SESSION that are idle crossed the timelimit of MAX_IDLE_TIME limit the detailed steps for whcih are listed below.



*************************************************************************

Steps to Configure Resource Manager to kill INACTIVE SESSIONS in Oracle


*************************************************************************


1. Create a pending area for resource plan.


Exec dbms_resource_manager.create_pending_area();


2. Create a plan for kill inactive session after crossed idle time.


--Check the name already exists

SELECT plan,status,comments FROM dba_rsrc_plans;



--Create the plan

Exec dbms_resource_manager.create_plan( plan => 'Kill_INACTIVE_PLAN', comment => 'kill inactive sessions');


3. Create the consumer groups.


Exec dbms_resource_manager.create_consumer_group( consumer_group => 'LONG_RUN',comment =>'Privileged Users');

Exec dbms_resource_manager.create_consumer_group( consumer_group => 'SHORT_RUN',comment => 'Under Privileged Users');


4. Create directives for the plan in Resource manager

you can define directives which is used by different setting for configure different user to different directives that will use different time limit as following examples.


Exec dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan =>

'LONG_RUN', comment => '15 minutes', max_idle_time => 900);

Exec dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan =>

'SHORT_RUN', comment => '5 minute idle time', max_idle_time => 300);

EXEC dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan =>

'OTHER_RUN', comment => '1 Hour ideal time', max_idle_time => 3600);


5. Submit the plan in Resource Manager.


Exec dbms_resource_manager.validate_pending_area();

Exec dbms_resource_manager.submit_pending_area();


6. Consumer group switching


begin

dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'SYSTEM',

consumer_group => 'LONG_RUN', grant_option => FALSE);

dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'TEST',

consumer_group => 'SHORT_RUN', grant_option => FALSE);

end;

/


7. Change database users default consumer groups:

Assign user SYSTEM to the group LONG_RUN

Assign user TEST to the group SHORT_RUN


begin

dbms_resource_manager.create_pending_area();

dbms_resource_manager.set_initial_consumer_group( user => 'SYSTEM', consumer_group => 'LONG_RUN');

dbms_resource_manager.set_initial_consumer_group( user => 'TEST', consumer_group => 'SHORT_RUN');

dbms_resource_manager.validate_pending_area();

dbms_resource_manager.submit_pending_area();

end;

/


8. Change resource plan for database and make it active.


alter system set resource_manager_plan='Kill_INACTIVE_PLAN';


9. Check query start using the new resource plan

SYSTEM user assigned to LONG_RUN and TEST user assigned to SHORT_RUN and the rest of the users with OTHER_RUN


SELECT sid,serial#,username,resource_consumer_group FROM gv$session;





ORACLE MOS NOTE: >>> Too Many SO_TIMEOUT And Inactive Database Sessions After Upgrading to WebLogic 12.2.1.4 (Doc ID 2814178.1)



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



************query to confirm the rows


select s.plan_hash_value,s.sql_id

,s.executions_delta

,s.elapsed_time_delta

,s.rows_processed_delta

,rows_processed_total

--,round(((s.elapsed_time_delta/1000000)/s.executions_delta),2) avg_elap_in_seconds

,s.cpu_time_delta

,n.begin_interval_time

,n.end_interval_time

,s.*

from dba_hist_Sqlstat s,dba_hist_snapshot n where

--s.instance_number=4

1=1

and s.snap_id=n.snap_id and s.instance_number=n.instance_number

--and s.executions_delta>0

and n.begin_interval_time between to_timestamp('10-Feb-2022 16:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('11-Feb-2022 23:00:00','DD-MON-YYYY HH24:MI:SS')

and s.sql_id='59ymgucb5hhyy'

--and s.sql_id='frv6z0mjuckw9'

order by s.snap_id;


*****************************


select * from XXCPF_FND_CONC_REQ_ARCHIVE

where concurrent_program_id=32781

and request_id in(123729691,123729683,122058441,122058432)

order by actual_start_date desc;


select * from xxcpf_pm_snapshot where prog_id=32781;


select owner,object_name,status,object_type from dba_objects where object_name like 'PO_REQUISITION_LINES_ALL';



---------------

select * from XXCPF_FND_CONC_REQ_ARCHIVE

where concurrent_program_id=32781

and request_id in(123729691,123729683,122058441,122058432)

order by actual_start_date desc;


select * from xxcpf_pm_snapshot where prog_id=32781;




https://www.oradev.com/hints.jsp *********** for Hints 


****Josh******  Temp Usage  query


The query used to gather the necessary set of information is listed below :


select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig 

from DBA_HIST_ACTIVE_SESS_HISTORY 

where 

sample_time > sysdate-30 and 

TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) 

group by sql_id order by sql_id;


This is a great feature of these ASH views.  Now we can go back in time and find the queries that were using all the temp space and tune them.


++++++++++++++++++++++++++


Hi Madan,


FOR CFNPRD ANALYSIS


use this query to find top request id which run for longest time. and then try to find session details and top SQL id for that request

SELECT fcr.request_id,

fcr.concurrent_program_id prog_id,

fcp.concurrent_program_name prog_name,

fcp.application_id app_id,

fcr.parent_request_id parent,

DECODE (fcr.phase_code,

'C', 'Completed',

'I', 'Inactive',

'P', 'Pending',

'Running', 'Unknown')

Phase,

DECODE (fcr.status_code,

'D', 'Cancelled',

'U', 'Disabled',

'E', 'Error',

'M', 'No Manager',

'R', 'Normal',

'I', 'Normal',

'C', 'Normal',

'H', 'On Hold',

'W', 'Paused',

'B', 'Resuming',

'P', 'Scheduled',

'Q', 'Standby',

'S', 'Suspended',

'X', 'Terminated',

'T', 'Terminating',

'A', 'Waiting',

'Z', 'Waiting',

'G', 'Warning',

'Unknown')

Status,

fcr.Argument_text,

fcr.requested_start_date,

fcr.actuaL_start_date,

fcr.actual_completion_date,

ROUND (

(fcr.actual_completion_date - fcr.actual_start_date)

* 24

* 60

* 60,

2)

|| 'secs/'

|| ROUND (

(fcr.actual_completion_date - fcr.actual_start_date) * 24 * 60,

2)

|| 'mins/'

|| ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24,

2)

|| 'hrs'

Time,ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24,

2) hrs

FROM apps.fnd_concurrent_requests fcr, apps.fnd_concurrent_programs fcp

WHERE 1 = 1

AND fcr.concurrent_program_id = fcp.concurrent_program_id

--AND (fcr.request_id = :req_id or fcr.parent_request_id=:req_id)

AND fcr.concurrent_program_id = :prog_id

ORDER BY hrs DESC

after getting top SQL just see its execution History and compare the stats before and after update.

based on that u need to provide observation.

Aditya Thakur Yesterday, 10:54 PM


if you are not getting any details in xxcpf_snapshot table then use


select * from XXCPF_FND_CONC_REQ_ARCHIVE where request_id=123752626


to find session details and if no session details are there in this table also then u can mention as no details found.



+++++++++++++++++++++++++++++++++++++++++



*****************  Main querys shared by suraj to check Temp/undo SQL from DATABASE


Temp available space


SELECT inst_id,

         tablespace_name,

         ROUND ( (free_blocks * 8) / 1024 / 1024, 2) FreeSpaceInGB,

         ROUND ( (used_blocks * 8) / 1024 / 1024, 2) UsedSpaceInGB,

         ROUND ( (total_blocks * 8) / 1024 / 1024, 2) TotalSpaceInGB

    FROM gv$sort_segment

   WHERE tablespace_name LIKE '%TEMP%'

ORDER BY 1, 2;



Top Temp SQLs


  SELECT /*+ parallel(8) */

        sql_id,

         MAX (sql_plan_hash_value)                       plan_hash,

         MAX (TEMP_SPACE_ALLOCATED) / (1024 * 1024 * 1024) gig,

         MAX (program)                                   program,

         MAX (module)                                    module,

         (SELECT username

            FROM dba_users

           WHERE user_id = a.user_id)

            username

    FROM DBA_HIST_ACTIVE_SESS_HISTORY a

   WHERE  TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) -- over 50 GB (change as per size of your instance temp space)

              AND sample_time > SYSDATE - 21 AND instance_number = :inst_id

GROUP BY sql_id, a.user_id

ORDER BY 3 DESC NULLS LAST;




Top UNDO SQLs


  SELECT b.sql_id,

         MAX (a.sql_hash_value) sql_hash,

         MAX (a.osuser)       osuser,

         MAX (a.username)     username,

         MAX (mb_used_ublk),

         SUM (mb_used_ublk),

         MAX (a.inst_id)      inst_id,

         MAX (a.program)      program,

         MAX (a.module)       module

    FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b

   WHERE     a.snap_date_time > SYSDATE - :no_of_days

         AND sql_hash_value != 0

         AND a.sql_hash_value = b.sql_hash

         AND a.inst_id = :inst_id

GROUP BY b.sql_id

  HAVING MAX (mb_used_ublk) > 500

ORDER BY 5 DESC




*********************



To send test page :


rmo-perf@epage.cisco.com


and https://mailer.cisco.com/ for getting notification of pager duity


need to add id in https://naas.cisco.com/epage/calendar/rmo-perf 


To check bind peeks :

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


select * from table(dbms_xplan.display_awr ('dwh6crb9kv06n', format => 'TYPICAL +PEEKED_BINDS'))


To get Size of the DB :

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


col "Database Size" format a20

col "Free space" format a20

col "Used space" format a20

select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size"

, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -

round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space"

, round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"

from (select bytes

from v$datafile

union all

select bytes

from v$tempfile

union all

select bytes

from v$log) used

, (select sum(bytes) as p

from dba_free_space) free

group by free.p

/


O/p:


Database Size Used space Free space

66582 GB 57576 GB 9006 GB



https://dba.cisco.com/dba-portal/tools/session-details ====== trace 


################################### Quer's to check undo usage :


select a.sid, a.serial#, a.username, b.used_urec used_undo_record, b.used_ublk used_undo_blocks

from gv$session a, gv$transaction b

where a.saddr=b.ses_addr ;


Check the SQL TEXT using or generating undo segments


select distinct(s.sql_id),s.sql_text from gv$sql s, gv$undostat u where u.maxqueryid=s.sql_id;

OR

select sql.sql_text, t.used_urec records, t.used_ublk blocks,

(t.used_ublk*8192/1024) kb from v$transaction t,

v$session s, v$sql sql

where t.addr=s.taddr

and s.sql_id = sql.sql_id;



Finding what's consuming the most UNDO


Very often DBA's see that one or more session seem to be hogging the UNDO tablespace.  


You need to find out what user and which SQL statement is eating up all the UNDO space.


SQL> 


select s.sql_text from gv$sql s, gv$undostat u

where u.maxqueryid=s.sql_id;


You can also use following SQL to find out most undo used by a session for a currently executing transaction.


SQL>


 select s.sid,s.username,t.used_urec,t.used_ublk

from gv$session s, gv$transaction t

where s.saddr = t.ses_addr

order by t.used_ublk desc;


To find out which session is currently using the most UNDO,


SQL>select s.sid, t.name, s.value

from gv$sesstat s, gv$statname t

where s.statistic#=t.statistic#

and t.name='undo change vector size'

order by s.value desc;



SQL>


select sql.sql_text, t.used_urec records, t.used_ublk blocks,

(t.used_ublk*8192/1024) kb from v$transaction t,

v$session s, v$sql sql

where t.addr=s.taddr

and s.sql_id = sql.sql_id

and s.username ='&USERNAME';



+++++++++++++++++++++++++ To check specific time timestamp for the query :

SELECT /*+parallel(8)*/ sql_id,

COUNT(*),

event

FROM gv$active_session_history

WHERE sample_time BETWEEN TO_DATE('16-mar-2022 22:40:29', 'DD-Mon-YYYY HH24:MI:SS') AND TO_DATE('16-mar-2022 22:53:05', 'DD-Mon-YYYY HH24:MI:SS')

AND upper(module) LIKE '%WINNERS_BATCH%'

AND sql_id = '4cb3ufq8126jb'

GROUP BY sql_id,

event

ORDER BY COUNT(1) DESC;






#################################################


when we have Program name :

++++++++++++++++++++++++++

 

 SELECT c.user_concurrent_program_name,

         a.concurrent_program_id,

         b.user_name,

         request_id,

         actual_start_date,

         actual_completion_date,

         SYSDATE,

         phase_code,

         status_code,

         request_id,

         ARGUMENT_TEXT

    FROM apps.fnd_concurrent_requests  a,

         apps.fnd_user                 b,

         apps.fnd_concurrent_programs_tl c

   WHERE a.concurrent_program_id = c.concurrent_program_id

     AND c.user_concurrent_program_name ='CTS FIN - Generate India Domestic Documents' 

     AND a.requested_by = b.user_id

--and status_code = 'R'

ORDER BY actual_start_date DESC


SELECT DISTINCT module

  FROM xxcpf_pm_snapshot

 WHERE     prog_id = 1261623



select sql_id,count(*) from xxcpf_pm_snapshot where module='e:XXCTS_SLM:cp:xxcts_plan/XXCTS_PLAN_C2S_PDL_DAT' group by sql_id order by 2 desc


Temp Usage : IMP

===========



select  sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig 

from DBA_HIST_ACTIVE_SESS_HISTORY 

where 1=1--TEMP_SPACE_ALLOCATED > (50*1024*1024*1024)   -- over 50 GB

AND sample_time > sysdate-2 

and insatcne_number = :instance_number 

group by sql_id order by 2 desc nulls last;




select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig

from DBA_HIST_ACTIVE_SESS_HISTORY

where 1=1--TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) -- over 50 GB

AND sample_time > sysdate-2

and insatcne_number = :instance_number

group by sql_id order by 2 desc nulls last;

instance_number*



Suraj suggested query TO CHECK Temp usage :

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

SELECT b.sql_id, a.sql_hash_value,

         a.osuser,

         a.username,

         MAX (mb_used_ublk),

         a.inst_id,

         a.program,

         a.module

    FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b

   WHERE a.snap_date_time > SYSDATE - :no_of_days AND sql_hash_value != 0 and a.sql_hash_value = b.sql_hash

   and a.inst_id= :inst_id

GROUP BY b.sql_id, a.sql_hash_value,

         a.osuser,

         a.username,

         a.inst_id,

         a.program,

         a.module

  HAVING MAX (mb_used_ublk) > 500


Sql Hanging or not  :

++++++++++++++++++



select sess_io.inst_id,

       sess_io.sid,

    sesion.sql_id,

       sess_io.block_gets,

       sess_io.consistent_gets,

       sess_io.physical_reads,

       sess_io.block_changes,

       sess_io.consistent_changes

  from gv$sess_io sess_io, gv$session sesion

 where sesion.sid = sess_io.sid and 

 sess_io.inst_id = sesion.inst_id and 

 sesion.sql_id='&sql_id'

   and sesion.username is not null ;"




select sess_io.inst_id,

       sess_io.sid,

       sess_io.block_gets,

       sess_io.consistent_gets,

       sess_io.physical_reads,

       sess_io.block_changes,

       sess_io.consistent_changes

  from gv$sess_io sess_io, gv$session sesion

 where sesion.sid = sess_io.sid and 

 sess_io.inst_id = sesion.inst_id

   and sesion.username is not null 



###################################################






*********************************


Instance Tuning :


select name,value from gv$parameter where name in 

('shared_pool_size','log_buffer','db_block_size','db_cache_size','sga_max_size','sga_target','memory_target','memory_max_target')


PGA :


select pga_target_for_estimate,pga_target_factor,estd_extra_bytes_rw from gv$pga_target_advice;




**************** VIMP


select m.sql_id ,m.sql_plan_hash_value ,p.id,

rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation,

p.object_name object,

p.cardinality card,

p.cost cost,

substr(m.status,1,4) status,

m.output_rows

from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

and p.child_address=m.sql_child_address

and p.plan_hash_value=m.sql_plan_hash_value

and p.id=m.plan_line_id

---AND s.sid = 2129

----AND s.inst_id = 4

AND s.sql_id = 'gp4k0b7s0wsth'

---AND substr(m.status,1,4) = 'EXEC'

and m.sql_exec_id= 67108869

AND s.inst_id = m.inst_id

AND s.inst_id = p.inst_id

and s.key = m.key

order by id



select sql_exec_id from gv$sql_plan_monitor where sql_id = 'gp4k0b7s0wsth' order by output_rows desc



PDB PLan change monitoring :


PERF_PDBPROD_SQL_MONITORING --- Procedure and PERF_PDBPROD_PLAN_Change --- Table


select distinct SQL_ID from xxcpf_pm_snapshot where SQL_ID IN(select SQL_ID from PERF_PDBPROD_PLAN_Change) and schema='PRE_ADMIN'


select * from PERF_PDBPROD_PLAN_Change where SQL_ID='1j4gyk642sn4a'


select * from PERF_PDBPROD_PLAN_Change


select  * from xxcpf_pm_snapshot


++++++++++++++


CREATE OR REPLACE PROCEDURE PERF11I.PERF_PDBPROD_SQL_MONITORING 

AS 


BEGIN

INSERT INTO PERF_PDBPROD_PLAN_CHANGE (SQL_ID,

                                      TOTAL_VERSION,

                                      REASON,

                                      LOG_TIME)

select

 sql_id,count(*) total_version,''

 ||decode(max(                UNBOUND_CURSOR),'Y',               ' UNBOUND_CURSOR'      ||'( '||SUM(DECODE(      UNBOUND_CURSOR,'Y',1,0))||')' )

 ||decode(max(             SQL_TYPE_MISMATCH),'Y',            ' SQL_TYPE_MISMATCH'       ||'( '||SUM(DECODE(   SQL_TYPE_MISMATCH,'Y',1,0))||')' )

 ||decode(max(            OPTIMIZER_MISMATCH),'Y',           ' OPTIMIZER_MISMATCH'       ||'( '||SUM(DECODE(  OPTIMIZER_MISMATCH,'Y',1,0))||')')

 ||decode(max(              OUTLINE_MISMATCH),'Y',             ' OUTLINE_MISMATCH'       ||'( '||SUM(DECODE(    OUTLINE_MISMATCH,'Y',1,0))||')')

 ||decode(max(            STATS_ROW_MISMATCH),'Y',           ' STATS_ROW_MISMATCH'       ||'( '||SUM(DECODE(  STATS_ROW_MISMATCH,'Y',1,0))||')')

 ||decode(max(              LITERAL_MISMATCH),'Y',             ' LITERAL_MISMATCH'       ||'( '||SUM(DECODE(    LITERAL_MISMATCH,'Y',1,0))||')')

-- ||decode(max(            SEC_DEPTH_MISMATCH),'Y',           ' SEC_DEPTH_MISMATCH'     ||'( '||SUM(DECODE(    SEC_DEPTH_MISMATCH,'Y',1,0))||''

 ||decode(max(           EXPLAIN_PLAN_CURSOR),'Y',          ' EXPLAIN_PLAN_CURSOR'       ||'( '||SUM(DECODE( EXPLAIN_PLAN_CURSOR,'Y',1,0))||')')

 ||decode(max(         BUFFERED_DML_MISMATCH),'Y',        ' BUFFERED_DML_MISMATCH'       ||'( '||SUM(DECODE(BUFFERED_DML_MISMATCH,'Y',1,0))||')')

 ||decode(max(             PDML_ENV_MISMATCH),'Y',            ' PDML_ENV_MISMATCH'       ||'( '||SUM(DECODE(   PDML_ENV_MISMATCH,'Y',1,0))||')')

 ||decode(max(           INST_DRTLD_MISMATCH),'Y',          ' INST_DRTLD_MISMATCH'       ||'( '||SUM(DECODE( INST_DRTLD_MISMATCH,'Y',1,0))||')')

 ||decode(max(             SLAVE_QC_MISMATCH),'Y',            ' SLAVE_QC_MISMATCH'       ||'( '||SUM(DECODE(   SLAVE_QC_MISMATCH,'Y',1,0))||')')

 ||decode(max(            TYPECHECK_MISMATCH),'Y',           ' TYPECHECK_MISMATCH'       ||'( '||SUM(DECODE(  TYPECHECK_MISMATCH,'Y',1,0))||')')

 ||decode(max(           AUTH_CHECK_MISMATCH),'Y',          ' AUTH_CHECK_MISMATCH'       ||'( '||SUM(DECODE( AUTH_CHECK_MISMATCH,'Y',1,0))||')')

 ||decode(max(                 BIND_MISMATCH),'Y',                ' BIND_MISMATCH'       ||'( '||SUM(DECODE(       BIND_MISMATCH,'Y',1,0))||')')

 ||decode(max(             DESCRIBE_MISMATCH),'Y',            ' DESCRIBE_MISMATCH'       ||'( '||SUM(DECODE(   DESCRIBE_MISMATCH,'Y',1,0))||')')

 ||decode(max(             LANGUAGE_MISMATCH),'Y',            ' LANGUAGE_MISMATCH'       ||'( '||SUM(DECODE(   LANGUAGE_MISMATCH,'Y',1,0))||')')

 ||decode(max(          TRANSLATION_MISMATCH),'Y',         ' TRANSLATION_MISMATCH'       ||'( '||SUM(DECODE( TRANSLATION_MISMATCH,'Y',1,0))||')')

 --||decode(max(        ROW_LEVEL_SEC_MISMATCH),'Y',       ' ROW_LEVEL_SEC_MISMATCH'     ||'( '||SUM(DECODE( ROW_LEVEL_SEC_MISMATCH,'Y',1,0))||''

 ||decode(max(                  INSUFF_PRIVS),'Y',                 ' INSUFF_PRIVS'       ||'( '||SUM(DECODE(        INSUFF_PRIVS,'Y',1,0))||')')

 ||decode(max(              INSUFF_PRIVS_REM),'Y',             ' INSUFF_PRIVS_REM'       ||'( '||SUM(DECODE(    INSUFF_PRIVS_REM,'Y',1,0))||')')

 ||decode(max(         REMOTE_TRANS_MISMATCH),'Y',        ' REMOTE_TRANS_MISMATCH'       ||'( '||SUM(DECODE(REMOTE_TRANS_MISMATCH,'Y',1,0))||')')

 ||decode(max(     LOGMINER_SESSION_MISMATCH),'Y',    ' LOGMINER_SESSION_MISMATCH'       ||'( '||SUM(DECODE(LOGMINER_SESSION_MISMATCH,'Y',1,0))||')')

 ||decode(max(          INCOMP_LTRL_MISMATCH),'Y',         ' INCOMP_LTRL_MISMATCH'       ||'( '||SUM(DECODE( INCOMP_LTRL_MISMATCH,'Y',1,0))||')')

 ||decode(max(         OVERLAP_TIME_MISMATCH),'Y',        ' OVERLAP_TIME_MISMATCH'       ||'( '||SUM(DECODE(OVERLAP_TIME_MISMATCH,'Y',1,0))||')')

 --||decode(max(         SQL_REDIRECT_MISMATCH),'Y',        ' SQL_REDIRECT_MISMATCH'     ||'( '||SUM(DECODE( SQL_REDIRECT_MISMATCH,'Y',1,0))||''

 ||decode(max(         MV_QUERY_GEN_MISMATCH),'Y',        ' MV_QUERY_GEN_MISMATCH'       ||'( '||SUM(DECODE(MV_QUERY_GEN_MISMATCH,'Y',1,0))||')')

 ||decode(max(       USER_BIND_PEEK_MISMATCH),'Y',      ' USER_BIND_PEEK_MISMATCH'       ||'( '||SUM(DECODE(USER_BIND_PEEK_MISMATCH,'Y',1,0))||')')

 ||decode(max(           TYPCHK_DEP_MISMATCH),'Y',          ' TYPCHK_DEP_MISMATCH'       ||'( '||SUM(DECODE( TYPCHK_DEP_MISMATCH,'Y',1,0))||')')

 ||decode(max(           NO_TRIGGER_MISMATCH),'Y',          ' NO_TRIGGER_MISMATCH'       ||'( '||SUM(DECODE( NO_TRIGGER_MISMATCH,'Y',1,0))||')')

 ||decode(max(              FLASHBACK_CURSOR),'Y',             ' FLASHBACK_CURSOR'       ||'( '||SUM(DECODE(    FLASHBACK_CURSOR,'Y',1,0))||')')

 ||decode(max(        ANYDATA_TRANSFORMATION),'Y',       ' ANYDATA_TRANSFORMATION'       ||'( '||SUM(DECODE(ANYDATA_TRANSFORMATION,'Y',1,0))||')')

 --||decode(max(             INCOMPLETE_CURSOR),'Y',            ' INCOMPLETE_CURSOR'     ||'( '||SUM(DECODE(     INCOMPLETE_CURSOR,'Y',1,0))||''

 ||decode(max(          TOP_LEVEL_RPI_CURSOR),'Y',         ' TOP_LEVEL_RPI_CURSOR'       ||'( '||SUM(DECODE( TOP_LEVEL_RPI_CURSOR,'Y',1,0))||')')

 ||decode(max(         DIFFERENT_LONG_LENGTH),'Y',        ' DIFFERENT_LONG_LENGTH'       ||'( '||SUM(DECODE(DIFFERENT_LONG_LENGTH,'Y',1,0))||')')

 ||decode(max(         LOGICAL_STANDBY_APPLY),'Y',        ' LOGICAL_STANDBY_APPLY'       ||'( '||SUM(DECODE(LOGICAL_STANDBY_APPLY,'Y',1,0))||')')

 ||decode(max(                DIFF_CALL_DURN),'Y',               ' DIFF_CALL_DURN'       ||'( '||SUM(DECODE(      DIFF_CALL_DURN,'Y',1,0))||')')

 ||decode(max(                BIND_UACS_DIFF),'Y',               ' BIND_UACS_DIFF'       ||'( '||SUM(DECODE(      BIND_UACS_DIFF,'Y',1,0))||')')

 ||decode(max(        PLSQL_CMP_SWITCHS_DIFF),'Y',       ' PLSQL_CMP_SWITCHS_DIFF'       ||'( '||SUM(DECODE(PLSQL_CMP_SWITCHS_DIFF,'Y',1,0))||')')

 ||decode(max(         CURSOR_PARTS_MISMATCH),'Y',        ' CURSOR_PARTS_MISMATCH'       ||'( '||SUM(DECODE(CURSOR_PARTS_MISMATCH,'Y',1,0))||')')

 ||decode(max(           STB_OBJECT_MISMATCH),'Y',          ' STB_OBJECT_MISMATCH'       ||'( '||SUM(DECODE( STB_OBJECT_MISMATCH,'Y',1,0))||')')

 --||decode(max(             ROW_SHIP_MISMATCH),'Y',            ' ROW_SHIP_MISMATCH'     ||'( '||SUM(DECODE(     ROW_SHIP_MISMATCH,'Y',1,0))||''

 ||decode(max(             PQ_SLAVE_MISMATCH),'Y',            ' PQ_SLAVE_MISMATCH'       ||'( '||SUM(DECODE(   PQ_SLAVE_MISMATCH,'Y',1,0))||')')

 ||decode(max(        TOP_LEVEL_DDL_MISMATCH),'Y',       ' TOP_LEVEL_DDL_MISMATCH'       ||'( '||SUM(DECODE(TOP_LEVEL_DDL_MISMATCH,'Y',1,0))||')')

 ||decode(max(             MULTI_PX_MISMATCH),'Y',            ' MULTI_PX_MISMATCH'       ||'( '||SUM(DECODE(   MULTI_PX_MISMATCH,'Y',1,0))||')')

 ||decode(max(       BIND_PEEKED_PQ_MISMATCH),'Y',      ' BIND_PEEKED_PQ_MISMATCH'       ||'( '||SUM(DECODE(BIND_PEEKED_PQ_MISMATCH,'Y',1,0))||')')

 ||decode(max(           MV_REWRITE_MISMATCH),'Y',          ' MV_REWRITE_MISMATCH'       ||'( '||SUM(DECODE( MV_REWRITE_MISMATCH,'Y',1,0))||')')

 ||decode(max(         ROLL_INVALID_MISMATCH),'Y',        ' ROLL_INVALID_MISMATCH'       ||'( '||SUM(DECODE(ROLL_INVALID_MISMATCH,'Y',1,0))||')')

 ||decode(max(       OPTIMIZER_MODE_MISMATCH),'Y',      ' OPTIMIZER_MODE_MISMATCH'       ||'( '||SUM(DECODE(OPTIMIZER_MODE_MISMATCH,'Y',1,0))||')')

 ||decode(max(                   PX_MISMATCH),'Y',                  ' PX_MISMATCH'       ||'( '||SUM(DECODE(         PX_MISMATCH,'Y',1,0))||')')

 ||decode(max(          MV_STALEOBJ_MISMATCH),'Y',         ' MV_STALEOBJ_MISMATCH'       ||'( '||SUM(DECODE( MV_STALEOBJ_MISMATCH,'Y',1,0))||')')

 ||decode(max(      FLASHBACK_TABLE_MISMATCH),'Y',     ' FLASHBACK_TABLE_MISMATCH'       ||'( '||SUM(DECODE(FLASHBACK_TABLE_MISMATCH,'Y',1,0))||')')

 ||decode(max(          LITREP_COMP_MISMATCH),'Y',         ' LITREP_COMP_MISMATCH'       ||'( '||SUM(DECODE( LITREP_COMP_MISMATCH,'Y',1,0))||')')

 reason, SYSDATE 

from

   gv$sql_shared_cursor

  where sql_id  in (select sql_id from (select sql_id , count(*) from (select sql_id, plan_hash_value, count(*)  from gv$sqlarea    group by SQL_ID , plan_hash_value  ORDER BY 3 DESC ) group by sql_id having count(*)>2  order by 2 desc ))

group by

   sql_id;

   

   END;

/


++++++++++++++++++++++++


Query to check Team usage :


select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig

from DBA_HIST_ACTIVE_SESS_HISTORY

where

sample_time > sysdate-3 and

TEMP_SPACE_ALLOCATED > (100*1024*1024*1024)

group by sql_id order by sql_id;




from Josh Arora (Cisco) to everyone: 9:34 PM

INC6160564 - PDBPROD

from Josh Arora (Cisco) to everyone: 9:35 PM

INC6142247 - Observing slowness in GTM --- TCPM Socket 

from Madan Kumar Kancharla (Cisco) to everyone: 9:46 PM

INC6159812



/*+ INDEX(v_employees.employees IDX_emp_id) */ ********  


/*+ INDEX(v_employees employees IDX_emp_id) */ **************



For request id given :



SELECT A.REQUEST_ID, D.SID, D.SERIAL# , C.SPID,A.PHASE_CODE

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 = &REQUEST_ID

---AND A.PHASE_CODE = ‘R’;

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

INC0674838 ---- ---- prem/suraj G2CPRD


/*+ materialize */


Bangalore Duo - SSL ===== use this to connect VPN (now)(adi and shilpa are using)


=== previously using Bangalore gem vpn 2 (Bangalore GEM VPN 2)


==== at hyd team told to use ==== Bangalore gem 2 DUO(BGL GEM 2 DUO)


===== +++++++++++++++++++

AWR snapshots for upgrde :




Step 1 :-


/* Formatted on 30-07-2021 12:10:58 (QP5 v5.294) */

  SELECT DISTINCT CONCURRENT_PROGRAM_ID,

                  MIN (TIME),

                  MAX (TIME),

                  AVG (TIME)

    FROM (SELECT Concurrent_program_id,

                 ROUND (

                    (actual_completion_date - actual_start_date) * 24 * 60 * 60,

                    2)

                    time

            FROM apps.fnd_concurrent_requests

           WHERE ACTUAL_START_DATE BETWEEN TO_DATE ('07/28/2021 00:00:00',

                                                    'MM/DD/RRRR HH24:MI:SS')

                                       AND TO_DATE ('07/28/2021 04:00:00',

                                                    'MM/DD/RRRR HH24:MI:SS'))

GROUP BY CONCURRENT_PROGRAM_ID;





/* Formatted on 03/08/2021 18:19:11 (QP5 v5.294) */

SELECT DISTINCT DV1.program_id,

       PRD.program_name,

       DV1.min_time,

       DV1.max_time,

       DV1.Avg_time,

       PRD.min_time,

       PRD.max_time,

       PRD.avg_time

  FROM dv1cl1_28july DV1, CL1PRD_28JULY PRD WHERE DV1.PROGRAM_ID = PRD.PROGRAM_ID

-- GROUP BY DV1.PROGRAM_ID ;

  


UPDATE cl1prd_28july bb  set program_name = ( select distinct  AA.USER_CONCURRENT_PROGRAM_NAME from apps.fnd_concurrent_programs_tl AA where to_number (AA.concurrent_program_id ) = to_number (program_id)



+++++++++++++++++++++++++++++++++ suraj


select m.sql_id ,m.sql_plan_hash_value ,p.id,

rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation,

p.object_name object,

p.cardinality card,

p.cost cost,

substr(m.status,1,4) status,

m.output_rows

from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

and p.child_address=m.sql_child_address

and p.plan_hash_value=m.sql_plan_hash_value

and p.id=m.plan_line_id

-- AND s.sid = 5756

--AND s.inst_id = 1

AND s.sql_id = '63tnpagfcwchh'

-- AND substr(m.status,1,4) = 'EXEC'

and m.sql_exec_id= 150998576

AND s.inst_id = m.inst_id

AND s.inst_id = p.inst_id

and s.key = m.key

order by id



select sql_exec_id from gv$sql_plan_monitor where sql_id = '63tnpagfcwchh' order by output_rows desc -- get the sql exec id


Hi,


The concurrent job "Cisco TSL FCM Rec Interface Extract" in G2CPRD is continuously failing . Please find attached the TRACE files from a recent execution. Could you please help us figure out the reason for this issue. 


Please note that I have attached the Trace files from G2CPRD as well as ODSPROD since the job calls a package in SCAADM@ODSPROD. 


Feel free to revert if you need further information.


Regards,

Ciciliya

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

Performance Tuning (Standalone and RAC):

1. Database Performance Issue

2. AWR – How to read

3. ASH – How to read

4. System State Dump – How to capture and how to read them

5. 10046/10053/error stack

6. RAC specific database tuning parameters

7. Automatic SQL Tuning

8. Tools

9. Identifying and Tuning SQL Problems 

10. ADDM

11. Tuning SQL & Tuning Optimizer and Execution Plan

12. Recommendations or Suggestions

13. Other Tools

14. Some frequently asked questions  



PL/SQL lock timer



Run this and tell me the output -


SELECT vs.inst_id,vs.osuser,vw.event,vw.p1,vw.p2,vw.p3 ,vt.sql_text , vs.program

FROM gv$session_wait vw, gv$sqltext vt , gv$session vs

WHERE vw.event = 'PL/SQL lock timer'

AND vt.address=vs.sql_address

AND vs.inst_id = vw.inst_id

AND vs.sid = vw.sid;



Its acvross miultiple


INST_ID OSUSER EVENT P1 P2 P3 SQL_TEXT PROGRAM

---------- ------------------------------ ---------------------------------------------------------------- ---------- ---------- ---------- ---------------------------------------------------------------- ------------------------------------------------

8 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

3 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

5 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

2 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

9 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

4 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

1 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

7 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

10 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client

6 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client


10 rows selected.


select osuser,event,p1 from gv$session where event = 'PL/SQL lock timer';


05:37:17 SQL> select osuser,event,p1 from gv$session where event = 'PL/SQL lock timer';


OSUSER EVENT P1

------------------------------ ---------------------------------------------------------------- ----------

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0

oracle PL/SQL lock timer 0



select time_waited from gv$system_event where event = 'PL/SQL lock timer';05:39:22 SQL>


TIME_WAITED

-----------

220204867

397946472

397956417

397942965

397948362

397946252

397942670

397945583

397946523

397939424


10 rows selected.



SELECT

s.sid,

s.seconds_in_wait,

s.wait_class,

s.event,

s.p1text,

s.p1,

s.p1raw,

s.serial#,

s.program,

s.client_identifier,

s.terminal,

s.command,

ct.command_name,

s.service_name,

s.module,

s.action,

s.username,

s.machine,

s.sql_id,

st.sql_text, -- just the first 64 characters of the SQL text

st.hash_value

FROM gv$session s,

gv$sqltext st,

gv$sqlcommand ct

WHERE st.sql_id (+) = s.sql_id

AND st.piece (+) = 0

AND ct.command_type (+) = s.command

AND s.event = 'PL/SQL lock timer'

ORDER BY s.seconds_in_wait DESC;



Best way to fix this is

grant public to all users

This event is called through the DBMSLOCK.SLEEP procedure or

USERLOCK.SLEEP procedure. This event is most likely to come from

user written stored procedures.

pushed back to the application support team to amend the code to reduce the amount of time this particular job spent sleeping.

This is not our issue

the issue is with application code for sure



GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP;

or you can tell dba to perform -

GRANT EXECUTE ON SYS.DBMS_LOCK TO PUBLIC;

for now

But this is just. STF

the permanent fix is to fix the actual code which needs to be taken care of by the application developers 


I checked across all the rac nodes

this is caused due to dbsmnp account

GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP;

This is the stf

Run this command in the database as STF

GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP;

Once the work is completed

then dba needs to revoke it


They need to be careful doing revoke

as it has an issue

Revoke Execute on SYS.DBMS_LOCK Errors With 'ORA-04021: timeout occurred while waiting to lock object' (Doc ID 2295290.1)

This is an expected behavior for explicit DDL commands...in case of revoke,it cannot leave other objects of the same user in inconsistent state. Hence, it can not go through with exclusive lock.

If the same execute was granted via the role, only have to revoke the role and it will succeed.

This is expected behavior.

If they run into that issue while doing the REVOKE

the solution is as follows -

1. Run revoke command when there is no transactions on the database.  Precisely when there is no session/transaction using the SYS.DBMS_LOCK package

or

2. Open the database in restrict mode per Document 337469.1 so that there will not be any user actions which could hold SYS.DBMS_LOCK



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

Top sql for ASH in 19C :

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


  SELECT sql_id,

         sql_plan_hash_value plan_hash_value,

         (SELECT username

            FROM dba_users

           WHERE user_id = ash.user_id)

            schema,

         MAX (program) program,

         MAX (module) module,

         MAX (action) action,

         MAX (machine) machine,

         COUNT (*) snapcount

    --  (select program_id from gv$sql  where sql_id=ash.sql_id and rownum =1) obj_id,

    --  (select o.object_name from perftest_objects o, gv$sql s where s.program_id =o.object_id and s.sql_id=ash.sql_id ) object_name,

    --  (select program_line# from gv$sql  where sql_id=ash.sql_id and rownum =1) line#

    FROM dba_hist_active_sess_history ash,

         (  SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid

              FROM dba_hist_snapshot

             WHERE (begin_interval_time) BETWEEN TO_DATE (20210728000000,

                                                          'YYYYMMDDHH24MISS')

                                             AND TO_DATE (20210728043000,

                                                          'YYYYMMDDHH24MISS')

          GROUP BY dbid) snap

   WHERE     ash.snap_id >= snap.min_snap_id

         AND snap_id <= snap.max_snap_id

         AND snap.dbid = ash.dbid

         AND user_id != 0

         AND sql_plan_hash_value != 0

         AND instance_number = :inst_id

         AND user_id NOT IN (SELECT user_id

                               FROM dba_users

                              WHERE username IN ('PERF11I',

                                                 'OPS$ORACLE',

                                                 'SYS',

                                                 'CISCO$SECURITY',

                                                 'DBSNMP'))

         AND machine NOT LIKE '%CISCO%'

         AND client_id NOT IN ('SYSTEM')

         AND module NOT LIKE '%SYSADMIN%'

         AND session_type = 'FOREGROUND'

GROUP BY sql_id, sql_plan_hash_value, user_id

ORDER BY COUNT (*) DESC

--FETCH FIRST 30 ROWS ONLY



SQL * net from db link :

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

http://www.dba-oracle.com/t_sql_dblink_performance.htm



https://shaharear.blogspot.com/2009/02/drivingsite-sql-hint.html



http://www.moreajays.com/2013/01/sqlnet-message-to-dblink-sqlnet-message.html ****** main



https://msutic.blogspot.com/2011/02/sqlnet-message-tofrom-dblink-how-to.html



Query to check whether its Reading from UNdo/Not :

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


select EVENT,CURRENT_OBJ# , OBJECT_NAME , SUBOBJECT_NAME , OBJECT_TYPE , f.tablespace_name ,COUNT(*)

from dba_hist_active_sess_history , dba_objects d , dba_data_files f where

session_id =2693  and session_serial# =51184  and sql_id = '59fwvsqhk234t'

and snap_id between 160335 and  160357

AND d.object_id(+) = CURRENT_OBJ# and f.file_id = p1

GROUP BY

EVENT,CURRENT_OBJ# , OBJECT_NAME , SUBOBJECT_NAME , OBJECT_TYPE, f.tablespace_name

ORDER BY COUNT(*) DESC;


(******************

Caller: Mohit Amgaonkar (mamgaonk)

Service Offering:  Oracle Database

Summary: SVSPRD APPCLOUD schema data migration

Severity: 3 - Low

Priority: 5 - Standard


To check snapping :


SELECT MIN (snap_id), MAX (snap_id)

begin_interval_time from dba_hist_snapshot

WHERE begin_interval_time BETWEEN TO_DATE ('10/18/2021 16:00:00','MM/DD/YYYY HH24:MI:SS')

AND TO_DATE ('10/18/2021 18:00:00',

'MM/DD/YYYY HH24:MI:SS');


----

 MIN(SNAP_ID) BEGIN_INTERVAL_TIME

81670 81673


Query to get Top 100 Cpu SQL :

+++++++++++++++++++++++++++++


select * from 

(select s.sql_id, RANK() OVER (ORDER BY (max(s.CPU_TIME_TOTAL/s.executions_total)) DESC) cpu_rank,

RANK() OVER (ORDER BY (max(s.ELAPSED_TIME_TOTAL/s.EXECUTIONS_TOTAL)) DESC) elapsed_rank

from

   dba_hist_sqlstat s,

   dba_hist_snapshot sn

where

   sn.begin_interval_time between to_date('03-mar-2022 0001','dd-mon-yyyy hh24mi')

and

   to_date('05-apr-2022 1100','dd-mon-yyyy hh24mi')

and

   sn.snap_id=s.snap_id and s.executions_total >0

group by

   s.sql_id

   ) where cpu_rank <=100 and elapsed_rank<=100;


select begin_interval_time FROM dba_hist_snapshot where snap_id=105890


*****************

HOST_NAME --- svs prd ==== 19.0.0.0.0

Old ----

dbc-prd2-2060

dbc-prd2-2058

dbc-prd2-2059

dbc-prd2-2057


New ---- ************

dbc-prd1-2060

dbc-prd1-2058

dbc-prd1-2059

dbc-prd1-2057

***************************************

G2CPRD : 12.1.0.2.0


HOST_NAME

dbc-prd1-2053

dbc-prd1-2052

dbc-prd1-2051

dbc-prd1-2054


coverage team: 

wip-coverage-support(mailer list) <wip-coverage-support@cisco.com>


Rohit Pal -X (rohpal - WIPRO LIMITED at Cisco)


Utpalendu Karmakar -X (ukarmaka - WIPRO LIMITED at Cisco)


Shaik Tamzum -X (stamzum - WIPRO LIMITED at Cisco)


otm-crediting :


wip-otm-crediting-support(mailer list)


Pravin Kumar -X (pravink3 - WIPRO LIMITED at Cisco)


Satheshkumar Murugan -X (sathesmu - WIPRO LIMITED at Cisco)


Keshav Mittal -X (kemittal - WIPRO LIMITED at Cisco)


Mancherla Jaswanth Reddy -X (mancredd - WIPRO LIMITED at Cisco)



OIC :


wipro_oic_support(mailer list)

Kottisa Sai -X (kotsai - WIPRO LIMITED at Cisco)


(OIC) for OIC


Oracle Incentive Compensation (OIC) ---- SO


GSE-GTMS-G2C-OIC-SME --- PM


GSE-GTMS-G2C-OIC --- AG


Kottisa Sai (kotsai) --- POC



==== NGCGi Team


khota@cisco.com  


 nehaag@cisco.com 

 knatolan@cisco.com


Schema :XXG2CCGI 






POC : 


wip-otm-crediting-support(mailer list) <wip-otm-crediting-support@cisco.com>;

wip-coverage-support(mailer list) <wip-coverage-support@cisco.com>;

wipro_oic_support(mailer list) <wipro_oic_support@cisco.com>



https://cisco.sharepoint.com/sites/ApplicationPerformanceManagement-DBSQLTuning  ********** Link shared By Manish(for Docs)


Tuning Database Instance Proactively Using ADDM Infrastructure  :

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

Going forward we can use the following customized query to report out all issues that need attention to improve your overall database performance based on different criteria: impact, rank, problem type etc...


The goal is to utilize Automatic Database Diagnostic Monitor (ADDM) infrastructure to help tune database instance problems/issues based on rank and impact and/or problem type.


SELECT a.Execution_end,

b.Type,

b.Impact,

d.Rank,

d.Type,

'Message : ' ||b.Message Message,

'Command To correct: ' ||c.Command Command,

'Action Message : ' ||c.Message Action_Message

FROM DBA_Advisor_Tasks a,

DBA_Advisor_Findings b,

DBA_Advisor_Actions c,

DBA_Advisor_Recommendations d

WHERE a.Owner=b.Owner

AND a.Task_ID = b.Task_ID

AND b.Task_ID = d.Task_ID

AND b.Finding_ID = d.Finding_ID

AND a.Task_ID = c.Task_Id

AND d.Rec_ID = c.Rec_ID

AND a.Task_Name LIKE 'ADDM%'

AND a.Status='COMPLETED'

Order By BY b.Impact,

d.Rank

 

An example output is presented below:

Execution End : 18-NOV-16

Type : Problem

Impact : 4.4961E+10

Rank : 2

Type : SQL Tuning

Message : SQL statements consuming significant database time were found. These statements offer a good opportunity for performance improvement.

Command To correct : RUN SQL TUNING ADVISOR

Action Message : Run SQL Tuning Advisor on the SELECT statement with SQL_ID "9wm3snv9jw4ng".

Execution End : 29-NOV-16

Type : Problem

Impact : 7522162

Rank : 2

Type : Application Analysis

Message : Waits on event "log file sync" while performing COMMIT and ROLLBACK operations were consuming significant database time.

Command To correct : UNDEFINED

Action Message : Investigate application logic for possible reduction in the number of COMMIT operations by increasing the size of transactions.


Cheers


Josh









***************************





INC3403444


Also, SIAPRD seems to have a lot of User IO issues and many queries need tuning. 

SIAPRD 


CTMPRD management could consider subscribing to performance team for proactive services (top sql analysis, host analysis and weekly/ bi-weekly meetings) by sending mail to perf-engage(mailer list).


30 10 * * 6 /auto/hosting/bin/Oracle/database/GatherStats/PRD/GatherStats.pl -i OTMPRD1 -d WEEKEND -x MANUAL

30 10 * * 0-5 /auto/hosting/bin/Oracle/database/GatherStats/PRD/GatherStats.pl -i OTMPRD1 -d WEEKDAY -x MANUAL


select * from gv$session where status='INACTIVE' and schemaname='SCD' and OSUSER='engadm' ******************



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

Hi Team,

As suggested gathered Histogram On VT_STATUS


SQL> /

Enter value for table_name: XXCP_VT_INTERFACE

Enter value for column_name: VT_STATUS

old 1: select owner,table_name,column_name,histogram,last_analyzed from DBA_TAB_COL_STATISTICS where table_name='&table_name' and column_name='&column_name'

new 1: select owner,table_name,column_name,histogram,last_analyzed from DBA_TAB_COL_STATISTICS where table_name='XXCP_VT_INTERFACE' and column_name='VT_STATUS'


OWNER TABLE_NAME COLUMN_NAME

-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------

HISTOGRAM LAST_ANALYZED

--------------- ------------------

XXCP XXCP_VT_INTERFACE VT_STATUS

HEIGHT BALANCED 24-FEB-21


the analyze is done and histogram is created


After that clear the cache and Re Run the Program and it Got completed as before

Issue Got fixed and Resolving the case.


Regards

Madan


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


SELECT COLUMN_NAME, NOTES, HISTOGRAM 

  2  FROM   USER_TAB_COL_STATISTICS 

  3  WHERE  TABLE_NAME = 'SALES2';



SQL> SELECT COUNT(*) FROM sales2 WHERE prod_id = 42;


  COUNT(*)

----------

     12116


SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER,'SALES2',OPTIONS=>'GATHER AUTO');




=========


SQL> select owner,table_name,TO_CHAR(last_analyzed,'MM/DD/YYYY HH:MI:SS') Last_Analyzed, global_stats from dba_tables where TABLE_NAME='OBJECT_LOCK';


OWNER TABLE_NAME LAST_ANALYZED GLOBAL_STATS

------------------------------ ------------------------------ ------------------------------------------------------------------------------------------ ------------------------------

GLOGOWNER OBJECT_LOCK 04/24/2021 10:32:04 YES



select event,sql_id, a.* from gv$session a where username = 'SCD' *************



An Ad-Hoc Query is a query that cannot be determined prior to the moment the query is issued.

It is created in order to get information when need arises and 

it consists of dynamically constructed SQL which is usually constructed by desktop-resident query tools



https://cisco.sharepoint.com/sites/ApplicationPerformanceManagement-DBSQLTuning/Shared%20Documents/Forms/AllItems.aspx

====

share your analysis over mail - 

1) why leading hint caused query to run longer in TS1? 

2)What are the alternate options. 

3) Why in original query maximum filtering was happening after xla_ae_headers, is it a combination of tables that cause filtering?


Please do make statement fix entry for the yesterday sqls of CG1PRD which has been worked upon

You can use below link for it

http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp ************ Statement fix entry



IO waits




then plan 


check each part of the query to find where exactly the issue issues



----


-- Check who is blocking who in RAC, including objects

SELECT DECODE(request,0,'Holder: ','Waiter: ') || gv$lock.sid sess, machine, do.object_name as locked_object,id1, id2, lmode, request, gv$lock.type

FROM gv$lock join gv$session on gv$lock.sid=gv$session.sid and gv$lock.inst_id=gv$session.inst_id

join gv$locked_object lo on gv$lock.SID = lo.SESSION_ID and gv$lock.inst_id=lo.inst_id

join dba_objects do on lo.OBJECT_ID = do.OBJECT_ID

WHERE (id1, id2, gv$lock.type) IN (

SELECT id1, id2, type FROM gv$lock WHERE request>0)

ORDER BY id1, request;


SESS MACHINE

------------------------------------------------ ----------------------------------------------------------------

LOCKED_OBJECT ID1 ID2

-------------------------------------------------------------------------------------------------------------------------------- ---------- ----------

LMODE REQUEST TY

---------- ---------- --

Holder: 1602 npr-prd-107

COLL_ENTITY_ENTPHYSICAL 66584577 2588339

6 0 TX


Waiter: 3195 npr-prd-103

COLL_ENTITY_ENTPHYSICAL 66584577 2588339

0 6 TX

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

-- Who is blocking who, with some decoding*********************


select OS_USER_NAME os_user,

PROCESS os_pid,

ORACLE_USERNAME oracle_user,

l.SID oracle_id,

decode(TYPE,

'MR', 'Media Recovery',

'RT', 'Redo Thread',

'UN', 'User Name',

'TX', 'Transaction',

'TM', 'DML',

'UL', 'PL/SQL User Lock',

'DX', 'Distributed Xaction',

'CF', 'Control File',

'IS', 'Instance State',

'FS', 'File Set',

'IR', 'Instance Recovery',

'ST', 'Disk Space Transaction',

'TS', 'Temp Segment',

'IV', 'Library Cache Invalidation',

'LS', 'Log Start or Switch',

'RW', 'Row Wait',

'SQ', 'Sequence Number',

'TE', 'Extend Table',

'TT', 'Temp Table', type) lock_type,

decode(LMODE,

0, 'None',

1, 'Null',

2, 'Row-S (SS)',

3, 'Row-X (SX)',

4, 'Share',

5, 'S/Row-X (SSX)',

6, 'Exclusive', lmode) lock_held,

decode(REQUEST,

0, 'None',

1, 'Null',

2, 'Row-S (SS)',

3, 'Row-X (SX)',

4, 'Share',

5, 'S/Row-X (SSX)',

6, 'Exclusive', request) lock_requested,

decode(BLOCK,

0, 'Not Blocking',

1, 'Blocking',

2, 'Global', block) status,

OWNER,

OBJECT_NAME

from v$locked_object lo,

dba_objects do,

v$lock l

where lo.OBJECT_ID = do.OBJECT_ID

AND l.SID = lo.SESSION_ID

and block=1


To check Blocking sessions :

-----------------------------


select * from gv$lock where block=1;

select count(*) from gv$lock where block=1;

select sid from gv$lock where block=1;


Result set :

OS_USER OS_PID ORACLE_USER ORACLE_ID LOCK_TYPE LOCK_HELD LOCK_REQUESTED STATUS OWNER OBJECT_NAME

-------------------------------------------------------------------------------------------------------------------------------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- ---------- -------------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------

netaware 28780 NETAWARE 708 Transaction Exclusive None Blocking NETAWARE


script to find best Plan for the query :

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


set lines 155

col execs for 999,999,999

col etime for 999,999,999.9

col avg_etime for 999,999.999

col avg_cpu_time for 999,999.999

col avg_lio for 999,999,999.9

col avg_pio for 9,999,999.9

col begin_interval_time for a30

col node for 99999

break on plan_hash_value on startup_time skip 1

select sql_id, plan_hash_value, 

sum(execs) execs, 

-- sum(etime) etime, 

sum(etime)/sum(execs) avg_etime, 

sum(cpu_time)/sum(execs) avg_cpu_time,

sum(lio)/sum(execs) avg_lio, 

sum(pio)/sum(execs) avg_pio

from (

select ss.snap_id, ss.instance_number node, begin_interval_time, sql_id, plan_hash_value,

nvl(executions_delta,0) execs,

elapsed_time_delta/1000000 etime,

(elapsed_time_delta/decode(nvl(executions_delta,0),0,1,executions_delta))/1000000 avg_etime,

buffer_gets_delta lio,

disk_reads_delta pio,

cpu_time_delta/1000000 cpu_time,

(buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta)) avg_lio,

(cpu_time_delta/decode(nvl(executions_delta,0),0,1,executions_delta)) avg_cpu_time

from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS

where sql_id = nvl('&sql_id','0j60rcf1sxwhn')

and ss.snap_id = S.snap_id

and ss.instance_number = S.instance_number 

-- and executions_delta > 0

)

group by sql_id, plan_hash_value

order by 5

/


Note : Click f5 and pass sql (in query also)

O/p:


SQL_ID        PLAN_HASH_VALUE        EXECS    AVG_ETIME AVG_CPU_TIME        AVG_LIO      AVG_PIO

------------- --------------- ------------ ------------ ------------ -------------- ------------

0j60rcf1sxwhn      1533718691           10      533.394      496.778   35,370,800.1    101,565.9

0j60rcf1sxwhn      2723961532           40      535.300      502.510   35,673,460.0     92,993.1

0j60rcf1sxwhn       976736611        1,322      596.614      520.524   36,311,123.0    326,966.5

0j60rcf1sxwhn      4048717372          151      565.509      523.587   36,539,770.6    101,053.9

0j60rcf1sxwhn      4058400253          649      565.257      525.656   36,787,799.1    102,553.3

0j60rcf1sxwhn      1482650650          435      603.618      532.059   36,580,169.4    351,073.9

0j60rcf1sxwhn      3087887237           91      575.177      534.807   36,833,093.6    103,455.5

0j60rcf1sxwhn      2630151508            4      609.285      538.745   35,620,276.3    352,627.3

0j60rcf1sxwhn      3604316931          486      620.117      543.302   37,384,418.4    360,170.0

0j60rcf1sxwhn      2932537873            1      585.594      543.806   35,661,039.0    110,443.0

0j60rcf1sxwhn      3099395911          453      637.179      550.498   37,488,353.2    356,781.2

0j60rcf1sxwhn      1754400160           97      598.251      553.059   37,493,150.8    107,679.8




========== To Know at which Object in the query consuming max time

SELECT ash.sql_plan_line_id,

       ash.sql_plan_operation,

       ash.sql_plan_options,

       p.object_name,

       round(100*COUNT(*)/

          sum(count(1)) over(), 2) "% time"

FROM gv$active_session_history ash,

        gv$sql_plan p

WHERE ash.sql_id = p.sql_id

AND ash.sql_plan_hash_value = p.plan_hash_value

AND ash.sql_plan_line_id = P.id

AND ash.sql_id = '&sql_id'

AND ash.sql_plan_hash_value = &plan_hash_value

GROUP BY ASH.SQL_PLAN_LINE_ID,

         ASH.SQL_PLAN_OPERATION,

         ASH.SQL_PLAN_OPTIONS,

         p.object_name

ORDER BY count(*) DESC

/

----

SELECT ash.sql_plan_line_id,

       ash.sql_plan_operation,

       ash.sql_plan_options,

       p.object_name,

       round(100*COUNT(*)/

          sum(count(1)) over(), 2) "% time"

FROM dba_hist_active_sess_history ash,

        gv$sql_plan p

WHERE ash.sql_id = p.sql_id

AND ash.sql_plan_hash_value = p.plan_hash_value

AND ash.sql_plan_line_id = P.id

AND ash.sql_id = '&sql_id'

AND ash.sql_plan_hash_value = &plan_hash_value

GROUP BY ASH.SQL_PLAN_LINE_ID,

         ASH.SQL_PLAN_OPERATION,

         ASH.SQL_PLAN_OPTIONS,

         p.object_name

ORDER BY count(*) DESC

/

-------------------------------------


SELECT ash.sql_plan_line_id,

       ash.sql_plan_operation,

       ash.sql_plan_options,

       p.object_name,

       round(100*COUNT(*)/

          sum(count(1)) over(), 2) "% time"

FROM dba_hist_active_sess_history ash,

      dba_hist_sql_plan/gv$sql_plan/xxcpf_pm_sql_plan   p

WHERE ash.sql_id = p.sql_id

AND ash.sql_plan_hash_value = p.plan_hash_value

AND ash.sql_plan_line_id = P.id

AND ash.sql_id = '&sql_id'

AND ash.sql_plan_hash_value = &plan_hash_value

GROUP BY ASH.SQL_PLAN_LINE_ID,

         ASH.SQL_PLAN_OPERATION,

         ASH.SQL_PLAN_OPTIONS,

         p.object_name

ORDER BY count(*) DESC

/

-------------


SELECT ash.sql_plan_line_id,

       ash.sql_plan_operation,

       ash.sql_plan_options,

       p.object_name,

       round(100*COUNT(*)/

          sum(count(1)) over(), 2) "% time"

FROM dba_hist_active_sess_history ash,

      dba_hist_sql_plan  p

WHERE ash.sql_id = p.sql_id

AND ash.sql_plan_hash_value = p.plan_hash_value

AND ash.sql_plan_line_id = P.id

AND ash.sql_id = '&sql_id'

AND ash.sql_plan_hash_value = &plan_hash_value

GROUP BY ASH.SQL_PLAN_LINE_ID,

         ASH.SQL_PLAN_OPERATION,

         ASH.SQL_PLAN_OPTIONS,

         p.object_name

ORDER BY count(*) DESC

/

--------

O/p :

SQL_PLAN_LINE_ID SQL_PLAN_OPERATION SQL_PLAN_OPTIONS OBJECT_NAME % time

108 TABLE ACCESS FULL DRF_CONTACT 46.43

32 TABLE ACCESS FULL DRF_CONTACT 40.66

169 SORT GROUP BY PIVOT 6.86

93 SORT GROUP BY PIVOT 5.23


https://cisco-my.sharepoint.com/:x:/p/vinandag/EWBT2oJumolGsJXV4jd6-pEBaOU5w8l_S9mVcAtwLhDNuQ?e=ZkaJsi -----***** PBI Tracker

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

HOST_NAME --- svs prd ==== 19.0.0.0.0

Old ----

dbc-prd2-2060

dbc-prd2-2058

dbc-prd2-2059

dbc-prd2-2057


New ----

dbc-prd1-2060

dbc-prd1-2058

dbc-prd1-2059

dbc-prd1-2057

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

sqlplus "/ as sysdba"

SQL> oradebug setmypid

SQL> oradebug unlimit;

SQL> oradebug -g all hanganalyze 3 

--wait for 30sec ------------

SQL> oradebug -g all hanganalyze 4

SQL> oradebug -g all systemstate 258 

SQL> oradebug -g all systemstate 258 

SQL> oradebug tracefile_name

SQL> exit

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

SVSPRD :


Shruthi Basavaraju -X (shrubasa - TATA CONSULTANCY SERVICES LIMITED at Cisco) <shrubasa@cisco.com>; 


Mark this Mailer alias


gsqs-csit-support(mailer list) gsqs-csit-support@cisco.com


----========

===========To Know where exactly query spending time


select nvl(event, session_state) event,

           round(100*count(*)/

             (sum(count(1)) over ()), 2) "% query time"

    from dba_hist_active_sess_history

    where sql_id = '&sql_id'

    group by nvl(event, session_state)

   order by count(*) desc



O/p :


EVENT % query time

ON CPU 90.74

direct path read temp 6.19

direct path write temp 1.82

db file sequential read 0.59




======= To check Historic SQL and its wait event for specifc interval

select sql_id,count(*)

from dba_hist_active_sess_history

where sample_time between to_date('07-NOV-19 18:00:00','DD-MON-YY HH24:MI:SS')

and to_date('04-DEC-19 21:00:00','DD-MON-YY HH24:MI:SS')

and event = '&event'

group by sql_id 

/

========To check elapse time

select

  SQL_ID

, PLAN_HASH_VALUE

, sum(EXECUTIONS_DELTA) EXECUTIONS

, sum(ROWS_PROCESSED_DELTA) CROWS

, trunc(sum(CPU_TIME_DELTA)/1000000/60) CPU_MINS

, trunc(sum(ELAPSED_TIME_DELTA)/1000000/60)  ELA_MINS

from DBA_HIST_SQLSTAT

where SQL_ID in (

'&sqlid')

group by SQL_ID , PLAN_HASH_VALUE

order by SQL_ID, CPU_MINS


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

PROMPT Session LongOps

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




SELECT a.sid,

       RPAD (a.opname, 30),

       a.sofar,

       a.totalwork,

       a.ELAPSED_SECONDS,

       ROUND ( ( (a.sofar) * 100) / a.totalwork, 3) "%_COMPLETED",

       time_remaining,

       RPAD (a.username, 10) username,

       a.SQL_HASH_VALUE,

       B.STATUS

  FROM GV$SESSION_LONGOPS a, gv$session b

 WHERE a.sid = &sid AND b.inst_id = &inst_id AND b.serial# = &serial AND a.sofar <> a.totalwork

/



********************

SVSPRD :


Shruthi Basavaraju -X (shrubasa - TATA CONSULTANCY SERVICES LIMITED at Cisco) <shrubasa@cisco.com>; 


edps-performance(mailer list) <edps-performance@cisco.com>


select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from v$session_longops where SID='5503';


       SID    SERIAL# OPNAME                                                                SOFAR  TOTALWORK TIME_REMAINING

---------- ---------- ---------------------------------------------------------------- ---------- ---------- --------------

      5503      57145 Table Scan                                                            67914    9647634        2472582

  

Hi Team,


Could you please share the session details of last quarter run It would be helpful for the analysis .

As per the history of the SQL , we could see only one entry in  history of the SQL.


Thanks & Regards,


select count(*) from PROFILE_ATTRIBUTE_VALUES@CPRRO_PRD --366058323 -- last 5days

select count(*) from ATTRIBUTE_DEFINITIONS@CPRRO_PRD --344

select count(*) from PERSONS@CPRRO_PRD cp --25504064

select count(*) from PROFILES@CPRRO_PRD cprof --25504086


plan_has wise high IO :

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


SELECT q.plan_hash_value,max(q.sql_id) sql_id,

Q.DBID,

(select reference from xxcpf_pm_sql_statement_fix where hash_value = q.plan_hash_value and rownum = 1 ) case_sql_hash_1,

SUM (q.EXECUTIONS_DELTA) executions,

SUM (DISK_READS_delta + DIRECT_WRITES_delta) pio_total,

SUM ((PHYSICAL_READ_BYTES_DELTA + PHYSICAL_WRITE_BYTES_DELTA) / (1024 *1024*1024)) PIO_GB ,

ROUND (SUM (DISK_READS_delta + DIRECT_WRITES_delta) / GREATEST (SUM (executions_delta), 1),

1)

pio_per_exec,

parsing_schema_name,

MODULE

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE 1 =1

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

and q.instance_number = :inst_id

AND q.plan_hash_value != 0

AND s.begin_interval_time > sysdate - 45

and parsing_schema_name not in ('PERF11I','OPS$ORACLE','SYS','DBSNMP')

group by

q.plan_hash_value ,parsing_schema_name,Q.DBID, MODULE

order by PIO_GB desc

fetch first 10 rows only


---dbc-prd2-2107


select sql_id,sql_opname, count(*) from gv$active_session_history where  module like '%dbc-prd2-2107%' group by sql_id,sql_opname order by 3 desc



select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE'))


select * from gv$sql where sql_id='a1pnz8mx41cdv'---dbc-prd2-2107(Host name)


select * from dba_db_links where db_link like '%XXCTS_XELUS_CTS%'


select * from gv$instance 


==== dbc-prd2-2107


create database link "perfctscsf"

connect to PERF11I

identified by "ts1cts#123#"

using 'TS1CTS_SRVC_OTH'



***************** FND stas


hi Haresh/Kartika,

as discussed please raise a task to ermo

exec fnd_stats.load_histogram_cols(action => 'INSERT', appl_id => 401, tabname => 'MTL_CYCLE_COUNT_ENTRIES', colname => 'ENTRY_STATUS_CODE', hsize => '100');

for creating histogram

for csfstg and csfprd

begin FND_STATS.GATHER_TABLE_STATS ('INV', 'MTL_CYCLE_COUNT_ENTRIES', percent => 10, degree => 20, granularity => 'ALL', INVALIDATE => 'N', cascade => TRUE); end;

in case fnd_stats has to gathered manually post histogram creation if not done automatically


****************************



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


plan_has wise high IO :

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


SELECT q.plan_hash_value,max(q.sql_id) sql_id,

Q.DBID,

(select reference from xxcpf_pm_sql_statement_fix where hash_value = q.plan_hash_value and rownum = 1 ) case_sql_hash_1,

SUM (q.EXECUTIONS_DELTA) executions,

SUM (DISK_READS_delta + DIRECT_WRITES_delta) pio_total,

SUM ((PHYSICAL_READ_BYTES_DELTA + PHYSICAL_WRITE_BYTES_DELTA) / (1024 *1024*1024)) PIO_GB ,

ROUND (SUM (DISK_READS_delta + DIRECT_WRITES_delta) / GREATEST (SUM (executions_delta), 1),

1)

pio_per_exec,

parsing_schema_name,

MODULE

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE 1 =1

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

and q.instance_number = :inst_id

AND q.plan_hash_value != 0

AND s.begin_interval_time > sysdate - 45

and parsing_schema_name not in ('PERF11I','OPS$ORACLE','SYS','DBSNMP')

group by

q.plan_hash_value ,parsing_schema_name,Q.DBID, MODULE

order by PIO_GB desc

fetch first 10 rows only




select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE'))


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


SELECT host_name,inst_id FROM gv$instance; ==== (host name /inst ID)


SELECT *

FROM dba_hist_sqltext where

sql_id in (

     '51j8rh3t51x13',

);    

Gather stats Analyze request for user ( Manually)



Hi Umesh/ Team,


We are working on the Top SQLs at each Node level.

We will share the details Node wise by tomorrow EOD.



Thanks & Regards,



https://dba.cisco.com/dba-portal/tools/schema-browser/CG1PRD ( TO access all dba link)


http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp ============= StatementFix/InsertEntry


• https://dba.cisco.com  search with “schema browser”  search/select with schema and select/search object type as table and select/search the table which you want to analyze it

• Once the request submitted, it will punch the alert to Prod dashboard (both Prod & Non-Prod) along with link to approve it

• Once it is approved, Analyze will submit and requestor will get auto notification once it is approved & analyzed

==========


execute dbms_stats.gather_index_stats(ownname => 'CTMRSRV1', indname => 'DBLOG_KEYSTMP', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE);

execute dbms_stats.gather_index_stats(ownname => 'CTMRSRV1', indname => 'DBU', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE);

execute dbms_stats.gather_table_stats(ownname => 'CTMRSRV1', tabname => 'CMR_DBLOG', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FOR ALL COLUMNS SIZE AUTO');


Please submit gather stats job and check again.,


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

How To Find Execution History Of An Sql_id  :


select a.instance_number inst_id, a.snap_id,a.plan_hash_value, to_char(begin_interval_time,'dd-mon-yy hh24:mi') btime, abs(extract(minute from (end_interval_time-begin_interval_time)) + extract(hour from (end_interval_time-begin_interval_time))*60 + extract(day from (end_interval_time-begin_interval_time))*24*60) minutes,

executions_delta executions, round(ELAPSED_TIME_delta/1000000/greatest(executions_delta,1),4) "avg duration (sec)" from dba_hist_SQLSTAT a, dba_hist_snapshot b

where sql_id='&sql_id' and a.snap_id=b.snap_id

and a.instance_number=b.instance_number

order by snap_id desc, a.instance_number;


if we have any non-perf related issues, we can route it to below service offering

SO:- Technical Help Desk

Support Level:- Tier 1

AG: TechSupport-Remote-GSTS-T1

this is what other support teams do

Today

Suraj Ramchander 12:00 AM


anything related to AppDynamics --> Application Performance Management --> APM-MaaS

anything related to load testing --> Application Performance Management --> APM-LTaaS



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

Dear Requester,


Thank you for contacting the dba team regarding your Incident/Service Request.

We are currently working on your case and will contact you for further information if needed, as well as notify you, when a resolution has been reached. If resolution of the issue is beyond the scope of our support, we will route it to the concerned team. Your patience during resolution process will be greatly appreciated.

You can also take a look at the DBA Self-Service URL at: https://dba.cisco.com/dbpharmacy/

Did you know, following tasks can be done easily without a case.


:-DB Doppler Utility - To Enable trace.

:-DB supplements - To add space to tablespace

:-DB Nerve - Validate/create/drop DB Links

DB Compiler - View/Compile invalid objects

:-DB Cure - To kill sessions

:-SSO Login Validation for ERP - validate single sign-on login for ERP database.

:-DB Availability Status- Check the availability of status of a DB.

:-All About DB - One stop shop for all DB related information

:-Analyze as a Self-Service - To Analyze the object

:-Check session details, Concurrent requests and terminate unwanted session from the database.


Many such useful activities can be done through tool.

Please use the self-service tools before opening a case with the DBA teams. You might get the required details readily available through the tool.


Thanks,

dba-ops-casesupport


-- To check given session in a given time frame


  SELECT /*+ index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/

        sql_id,

         SUM (

              NVL (NVL (delta_read_io_requests, 0), 0)

            + NVL (NVL (delta_write_io_requests, 0), 0))

            io_requests

    FROM dba_hist_active_sess_history ash,

         (  SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid

              FROM dba_hist_snapshot

             WHERE     TRUNC (begin_interval_time) > SYSDATE - 2

                   AND TRUNC (begin_interval_time) < SYSDATE + 1

          GROUP BY dbid) snap

   WHERE     ash.snap_id >= snap.min_snap_id

         AND snap_id <= snap.max_snap_id

         AND snap.dbid = ash.dbid

         AND ash.session_id = 689

         AND ash.session_serial# = 27737

         and ash.instance_number= 4

         --AND module like '%XXCP_CUSTOM_EVENTS%'

GROUP BY sql_id

ORDER BY 2 DESC


-- To check based on just the module name. ***********************


  SELECT  sql_id,

         SUM (

              NVL (NVL (delta_read_io_requests, 0), 0)

            + NVL (NVL (delta_write_io_requests, 0), 0))

            io_requests

    FROM gv$active_session_history ash

   WHERE  module like '%XXCP_CUSTOM_EVENTS%'

GROUP BY sql_id

ORDER BY 2 DESC

========

Hi All,


Today is my last working day at Cisco, as I have decided to pursue an opportunity outside. 

I would like to thank everyone with whom I have worked, helped me to grow and believed in my abilities.

I wish you all the very best for your future endeavors and I hope our paths cross again.


Please do stay in touch. 


Rgds

Ragesh


Monitoring Progress of a SQL Execution Plan :

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


column plan_line_id format 9999 heading 'LINE'

column plan_options format a10 heading 'OPTIONS'

column status format a10

column output_rows heading 'ROWS'

break on sid on sql_id on status

SELECT sid, sql_id, status, plan_line_id,

plan_operation || ' ' || plan_options operation, output_rows

FROM v$sql_plan_monitor

WHERE status not like '%DONE%' and sid='&sid' <---

ORDER BY 1,4;


-- OR ---


column plan_line_id format 9999 heading 'LINE'

column plan_options format a10 heading 'OPTIONS'

column status format a10

column output_rows heading 'ROWS'

break on sid on sql_id on status

SELECT sid, sql_id, status, plan_line_id,

plan_operation || ' ' || plan_options operation, output_rows

FROM v$sql_plan_monitor

WHERE status not like '%DONE%'

ORDER BY 1,4;


=============RE: TOP SQL's in CSFPRD 3/9/2021 perf db


Hi Umesh/Team,


We have completed the Top SQLs analysis w.r.t to CPU usage and High Disk Read consuming SQLs for all 6 Concurrent Nodes.


Please find below Key call outs of the analysis.


1) On  node 1 , two Spikes has been observed and identified top CPU consuming SQLs  for the peak duration .   Total 8 problematic SQLs identified  on Node 1 which consuming high CPU and disk reads.

2) On Node 2 , CPU usage is 25% through out the duration . No Spikes has been observed . Most of the concurrent program have  high executions.

3) On Node 4 , CPU usage is around 25% through out the duration . No spike has been observed , total 3 problematic SQL have encountered on Node 4 which consuming high disk reads.

4) On Node 6 , CPU usage is around 25% through out the duration . No spike has been observed ,  total 6 problematic SQLs have identified on Node 6 which contributing high disk read and CPU usage.

5) On Node 7 , CPU usage is around 25% through out the duration , No spike has been observed.  around 8 SQLs have identified on Node 7 which are contributing to High disk read and CPU usage.

6) On Node 9 , CPU usage  is around 25% through out the duration ,  No Spike has been observed , around  7 SQLs have found on Node 9 which are contributing to High Disk read and CPU usage.


We are opening the PBIs for the problematic SQLs and targeting to have recommendation till Friday for Node 1, Node 2 and Node 4.

Please find attached excel for the same.


Thanks & Regards,



======== To check Rows proccessed



select inst_id,Rows_processed,executions  from gv$sqlarea where sql_id='3a51njp3dhtjd'


select inst_id,Rows_processed,executions  from gv$sql where sql_id='3a51njp3dhtjd'


============================================Table Rebuild 


SQL> @/usr/tools/oracle/Standard/onCall/core/my_sid;


       PID        SID    SERIAL# SPID

---------- ---------- ---------- ------------------------

       419       5503      57145 42850


SQL> alter table xxrpth.xxrpt_coruser move parallel 16;



We see a total time remaining of 2472582 seconds , which is exceeding User's requirements , as their prod shareplex post is stopped , and they are seeing a big GG backlog . 


SQL> select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from v$session_longops where SID='5503';


       SID    SERIAL# OPNAME                                                                SOFAR  TOTALWORK TIME_REMAINING

---------- ---------- ---------------------------------------------------------------- ---------- ---------- --------------

      5503      57145 Table Scan                                                            67914    9647634        2472582


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


https://vahidhosseini-oracledba.blogspot.com/2015/11/enq-tx-row-lock-contention.html   ==== Good blogspot


https://dba.cisco.com/trace/trace/authAction.do  ========== Trace file


INC3120619--- EPICPRD

enq: TX - row lock contention:


This is indicative of a session waiting for a row lock held by another session.


when a session is waiting for a row level lock that is already held by another session. 


This occurs when one application is updating or deleting a row that another session is also trying to update or delete. 


This will generate a wait event "enq: TX - row lock contention".


To solve this particular issue, the session holding the lock must perform a COMMIT or ROLLBACK.


There are several situations of TX enqueue:


In mode 6:


Waits for TX in mode 6 occur when a session is waiting for a row level lock that is already held by another session. This occurs when one application is updating or deleting a row that another session is also trying to update or delete. This will generate a wait event "enq: TX - row lock contention". To solve this particular instance, the session holding the lock must perform a COMMIT or ROLLBACK.


In mode 4:we have 3 reasons:


  1.     Unique key contention:


     In mode 4, a TX wait can occur if there is a potential duplicate in a unique index. When two sessions try to insert the same key value the second session must wait to see if an ORA-001 should be raised. This can cause the "enq: TX - row lock contention" wait event. This wait event can be handled by having the session holding the lock perform a COMMIT or ROLLBACK.


  2.     Foreign Key contention:


If referential constraints have been defined between tables and the foreign key columns in the child table are not indexed, then modifications to the parent table's key cause locks on the child table, and if the foreign key columns are not indexed this can cause contention.


  3.     Bitmap index contention:


The wait event “enq: TX – row lock contention” can also occur in mode 4 when a session is waiting on a shared bitmap index fragment. Bitmap indexes index key values and a range of ROWIDs. Each entry in a bitmap index can cover many rows in the actual table. If two sessions want to update rows covered by the same index fragment, then the second session must wait for the first session to perform either a COMMIT or a ROLLBACK by waiting for the TX lock in mode 4, otherwise it will generate the “enq: TX – row lock contention” wait event.  This index is suitable for data warehouse environments.



enq: HW - contention                  Configuration

enq: SQ - contention                   Configuration

enq: SS - contention                    Configuration

enq: ST - contention                   Configuration

enq: TM - contention                  Application

enq: TW - contention                  Administrative

enq: TX - allocate ITL entry       Configuration

enq: TX - index contention         Concurrency

enq: TX - row lock contention      Application

enq: TX – contention                    Application


Step : 1 :


SELECT event, p1, MOD (p1, 16) AS "mode"

  FROM gv$active_session_history

 WHERE event ='enq: TX - row lock contention';


Step : 2:


select count(*) cnt, 

                 session_id sid,

                 substr(event,1,30) event, 

                 mod(p1,16)  as lm,

                 sql_id,

                 CURRENT_OBJ# || ' ' || object_name obj

               , o.object_type type

               , CURRENT_FILE# file#

               , CURRENT_BLOCK#  block#

               , blocking_session bsid

    from gv$active_session_history ash,

         all_objects o

    where

            event  like 'enq: T%'

      and o.object_id (+)= ash.current_obj#

   group by event,session_id,p1,sql_ID,CURRENT_OBJ#,OBJECT_NAME,OBJECT_TYPE,CURRENT_FILE#, CURRENT_BLOCK#, BLOCKING_SESSION

   order by  count(*);

   

Step :3:


  select    substr(event,1,30) event, sql_id,

             CURRENT_OBJ# || ' ' || object_name obj

           , o.object_type type

           , CURRENT_FILE# file#

           , CURRENT_BLOCK#  block#

    from v$active_session_history ash,

             ( select a.object_name, 

                      a.object_id,

                      decode(a.object_type,'INDEX',i.index_type||' '||'INDEX',a.object_type) object_type

               from all_objects a, all_indexes i where 

               a.owner=i.owner(+) and a.object_name=i.index_name(+) ) o

    where

            event  like 'enq: TX%'

      and o.object_id (+)= ash.current_obj#

    order by sample_time;




https://myapp.tcs.com/vpn/index.html ---------> For web mail


https://cisco.service-now.com/nav_to.do ----- INC2889129 


https://db-profiler.cisco.com/DBProfiler/ ---- New db profiler Tool


SELECT

output

FROM

TABLE

(dbms_workload_repository.awr_report_text

(DBID,instance,minsnap,maxsnap)

);


SELECT

output

FROM

TABLE

(dbms_workload_repository.awr_report_html

(3370857963,2,42405,42411)

);


select distinct(count(session_id)) from dba_hist_active_sess_history where current_obj#=68731 and snap_id between 145438 and 145479


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

Sub : Pager Swap Notification for Upcoming week


perf-db-ind(mailer list) <perf-db-ind@cisco.com>


Manish Mantri -X (manmantr - TATA CONSULTANCY SERVICES LIMITED at Cisco) <manmantr@cisco.com>


Hi Team,


Madan and I will be swapping morning pager shift for upcoming week.


PTO 


Premachand is on PTO on Today (25 Aug 2020) due to personal reasons.


oracle database --- so


DBA_ORACLE--- ag


APPLICATION PERF MANAGEMENT ---- SO

apm_DB --- ag


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

RAOPRD: 


Causing Service Offering - Billing Invoice and Revenue - Non Standard Revenue (NextGen CCRM)

Problem Manager AG - GSE-CVC-FIN-I2C-PBM-MGR

Problem Manager - Raghu Jalapati (rjalapat)

Assignment Group - GSE-CVC-FIN-I2C-NGCCRM

Assigned To - Sudhakar Muppidi (sumuppid)


 

Thanks Subrat.


We will take it forward from here.


Regards


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


*************** Steps to raise acess request for Oracle support and OEM :


OEM Tool Access

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

1. Go to https://oneaccess.cisco.com/home.jsf

2. Click on Manage User Access

3. Search for ccid eg, subpatra

4. Tick the employee Check box, then click NEXT

5. Search for EMPRD, then click on Oracle Enterprise Manager EMPRD - performance team role

6. Review and add Comments and Submit


OEM Tool Link : https://emprd-op.cisco.com/em/faces/logon/core-uifwk-console-login

Login with CISCO credentials. 


Provide only ccid. (Don't give @cisco.com) cisco login pass


for OEM  partcular user login :


Username will be : perf11i

PWD will be : dbname#123#


Oracle Support Access

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

1. Go to https://support.oracle.com/portal/?

2. Click on View Accounts --> Oracle Account --> Create an account

3. Fill the details. Provide CISCO id. eg, Email : subpatra@cisco.com

4. Add CSI : 15403044, 14247247, 14054935

5. You'll get a confirmation mail from Oracle after few days. You'll get to know with whom the request is pending with. We can ping them seeking approvals.



My Oracle account details :

+++++++++++++++++++++++++++

https://support.oracle.com/portal/?


user Name and Password :


makancha@cisco.com


Pass : Madhan@143


++++++++++++++++++++++++++++++++++


Hi Team,


Please provide the following information:


1. Is this an existing issue in production?

2. Which database?

4. Application Name?

5. What is the name of the program/ form/ report /business process that is having performance issue?

6. First Reported Time

7. Expected/Previous runtime statistics of program execution

8. Any recent changes (code/data/others)? If yes details about the changes.

9. Frequency of the program to be executed in production

10. Is the problem reproducible on a non-production environment

11. Details of a non production environment where team attempted to reproduce the problem

12. Whether tables used in the problematic sql/programs are at least 10% analyzed.

13. " LEVEL-12 TKPROF " sorted by "fchela exeela prsela" attached to the case ( Please contact DBA if required).

14. Both, a) Technical point-of-contact Onshore b) Technical point-of-contact Offshore ( for analysis and resolution support and participation for the issue)

15. Brief description of query functionality

16: Is AppDynamics enable for your application ? If YES then provide us details (application name , tires etc) ?


Regards

Performance Team


Hi Team,

please mention the SID/ Serial#, SQL ID and enable level 12 TKProf for the same and attach it to the case....

also please mention the time duration when this issue is observed along with the TZ info so that we could check the database

Regards

Performance Team





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


Hi Team, 

Please find the attached analysis and SQL profile


HI Team, 

Suggestion has been provided for the problematic SQL f5bg7td65tra9 related to call APPS.XXCPD_LPS_NPI_INCR_LOAD_PKG.xxcpd_status_prc(:1 ,:2 ,:3 ,:4 ) 

but later on as per shared session details another two SQL was coming at top, 

so requesting to share problematic SQL session details and TKPROF for the same to find out same, 

and if problematic SQL's are different please create separate case, as already created two. 

Apart from that for this case for f5bg7td65tra9 which was coming top SQL and after modification LIO became much less, 

and number of row executed also increase and from 9th onwards no plan change observed. 

In such a case share the problematic session while executing program and confirm us to close this case after monitoring f5bg7td65tra9 

for few days.


Hi Team,


Kindly update below questionnaires.


Hi Bramha, 

As checked in attached TKPROF, problematic delete statement is not captured, 

suggesting to perform de fragmentation and deploy sqlprofile 

later on generate 12-level TKPROF with proper session details for further validation.


INC2512727 - mention this... if the sid/ serial# is identifiable.... 

please mention the SID/ Serial#, time of the issue along with TZ and enable level 12 TKProf for the same and attach it to the case....

 if not, then also please mention the time duration when this issue is observed along with the TZ info so that we could check the database for that duration and identify problems if any

 

 INC2513888 - mention this... please let us know if this is a performance issue in production... if not, then, please move it to the correct SO/ AG


select * from gv$version --- to check version


select * from gv$parameter---- to check parametr


http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp


https://cisco.service-now.com/nav_to.do?uri=%2Fhome.do%3F---- snow


https://directory.cisco.com/dir/


https://dba.cisco.com/AllAboutDB ========= All about DB


https://dba.cisco.com/AllAboutSQL/ =============== All abou sql


Performance team is no longer providing the support for Non-PROD environments. If the teams know which SQL is causing issue they can use the DB Profiler to get the recommendations.


DB Profiler: https://db-profiler.cisco.com/DBProfiler/


Please provide us the level 12 tkprof report pre and post modifications of the sql for signoff from performance end .This modifications in the sql will lead to less and constant LIO for the sql . 


INC2181628---> Pratik sanpshot too old error -------> INC2409675


Regarding INC2286251---can i resolve the case?



marked pending for any queries on suggestions given.


analysis updated, marked pending for any queries. case will be resolved after 2 reminders.


reminder 1 to update if any further queries or the issue has been resolved.


resolving the case as there is no followup from the user and nothing is pending from our side.


Analysis updated and Resolving the case after user confirmation


Hi Team,


Analysis updated and Resolving the case as pending target passed


Regards

Madan


we have cancelled this case..It's Because SLA Breached 


we have created new case INC2487549 instead of this current case.


There is no reduction in execution count for the top SQL for this program, see attachment for details. Marked pending for any queries, 2 reminders will be given.


++++++++++++++++++++++++++++


select event,sql_id, a.* from gv$session a where username = 'WDPUB'




select m.sql_id ,m.sql_plan_hash_value ,p.id,

rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation,

p.object_name object,

p.cardinality card,

p.cost cost,

substr(m.status,1,4) status,

m.output_rows

from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

and p.child_address=m.sql_child_address

and p.plan_hash_value=m.sql_plan_hash_value

and p.id=m.plan_line_id

-- AND s.sid = 5756

--AND s.inst_id = 1

AND s.sql_id = '1v5tbzxag189n'

AND substr(m.status,1,4) = 'EXEC'

AND s.inst_id = m.inst_id

AND s.inst_id = p.inst_id

and s.key = m.key

order by id


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


SELECT                                       /*+ USE_NL(P) CARDINALITY(S 1) MONITOR*/

      S.SQL_HASH_VALUE,

       S.PLAN_HASH,

       S.EVENT_TYPE,

       S.P1,

       P.CHILD_NUMBER

  FROM XXCPF_PM_SNAPSHOT S, XXCPF_PM_SQL_PLAN P

 WHERE s.plan_hash = p.plan_hash


  select  sql_id from gv$session where sid = 761 AND inst_id = 1

  

  select * from gv$sql where sql_id = 'acxftamk29gbr'

  

  

  

    

  select FETCHES, BUFFER_GETS , DISK_READS , 'SQL'    from gv$sql where sql_id = '4qk105sn61usy'

  UNION  

  select  FETCHES, BUFFER_GETS , DISK_READS , elapsed_time from gv$sql_monitor where sid = &sid and inst_id = &inst_id  

  UNION

  select FETCHES, BUFFER_GETS , DISK_READS , 'SQLAREA'    from gv$sqlAREA where sql_id = '4qk105sn61usy'

  


**********************


Query to Obtain Information on Blocking Sessions 

--------------------------------------

--              Query 1             --

--------------------------------------


connect sys/<password> as sysdba 

set linesize 500 pagesize 200 


col inst_id format 99999 

col sid format 99999 

col spid format a6 

col blocking_session_status format a6 heading 'BS' 

col blocking_instance format 99 heading 'BI' 

col blocking_session format 99999 heading 'BLKSID' 

col session_type format a11 

col event format a31 

col file_name format a21 

col file_id format 9999999999999999999 

col call_counter format 9999999 

col wait_for_scn format 99999999999999 heading 'WAITING FOR' 

col wfscn format 99999999999999 heading 'WFSCN' 

col commit_wait_scn format 99999999999999 heading 'CWSCN' 

col post_commit_scn format 99999999999999 heading 'PCSCN' 

col clock format 99999999999999999999 heading 'CLOCK' 

col next_ticker format 999999999999999999999 heading 'NEXT TICKER' 


select wrt.inst_id, wrt.sid, wrt.serial#, wrt.spid, 

s.BLOCKING_SESSION_STATUS, s.BLOCKING_INSTANCE, 

s.blocking_session, 

wrt.session_type, wrt.event, 

wrt.file_name, wrt.file_id, wrt.call_counter, 

wrt.wait_for_scn, 

greatest(wrt.dependent_scn, wrt.statement_scn) as wfscn, 

wrt.commit_wait_scn, wrt.post_commit_scn, 

wrt.clock, wrt.next_ticker 

from gv$workload_replay_thread wrt, gv$session s 

where wrt.sid = s.sid 

and wrt.serial# = s.serial# 

order by inst_id, sid 

;


Query to Monitor the Approximate Progress of the Replay

--------------------------------------

--              Query 2             --

--------------------------------------


set echo off 


connect sys/<password> as sysdba 


set serveroutput on 


DECLARE 

my_next_ticker NUMBER; 

clock NUMBER; 

wait_for_scn NUMBER; 

counts NUMBER; 

replay_id NUMBER; 

thr_failure NUMBER; 

start_time DATE; 

num_tickers NUMBER; 

min_scn NUMBER; 

max_scn NUMBER; 

done NUMBER; 

total_time INTERVAL DAY TO SECOND; 


CURSOR get_next_ticker(my_next_ticker NUMBER) IS 

SELECT spid, event, inst_id, wrc_id, client_pid 

FROM gv$workload_replay_thread 

WHERE file_id = my_next_ticker; 


BEGIN 

dbms_output.put_line('********************************'); 

dbms_output.put_line('* Replay Status Report *'); 

dbms_output.put_line('********************************'); 


----------------------------------------- 

-- Make sure that a replay is in progress 

----------------------------------------- 

SELECT count(*) INTO counts 

FROM dba_workload_replays 

WHERE status='IN PROGRESS'; 


if (counts = 0) then 

dbms_output.put_line('No replay in progress!'); 

return; 

end if; 


------------------- 

-- Get replay state 

------------------- 

SELECT id,start_time INTO replay_id, start_time 

FROM dba_workload_replays 

WHERE status='IN PROGRESS'; 


SELECT count(*) INTO counts 

FROM gv$workload_replay_thread 

WHERE session_type = 'REPLAY'; 


SELECT min(wait_for_scn), max(next_ticker), max(clock) 

INTO wait_for_scn, my_next_ticker, clock 

FROM v$workload_replay_thread 

WHERE wait_for_scn <> 0 

AND session_type = 'REPLAY'; 


dbms_output.put_line('Replay has been running for: ' || 

to_char(systimestamp - start_time)); 

dbms_output.put_line('Current clock is: ' || clock); 

dbms_output.put_line('Replay is waiting on clock: ' || 

wait_for_scn); 

dbms_output.put_line(counts || ' threads are currently being 

replayed.'); 


---------------------------------------- 

-- Find info about the next clock ticker 

---------------------------------------- 

num_tickers := 0; 

for rec in get_next_ticker(my_next_ticker) loop 

-- We only want the next clock ticker 

num_tickers := num_tickers + 1; 

exit when num_tickers > 1; 


dbms_output.put_line('Next ticker is process ' || rec.spid || 

' (' || rec.wrc_id || ',' || rec.client_pid || 

') in instance ' || rec.inst_id || 

' and is waiting on '); 

dbms_output.put_line(' ' || rec.event); 


end loop; 


--------------------------------------------------------------------------------------- 

-- Compute the replay progression and estimate the time left 

-- Note: This is an estimated time only, not an absolute value as it is based on SCN.

--------------------------------------------------------------------------------------- 

SELECT min(post_commit_scn), max(post_commit_scn) 

INTO min_scn,max_scn 

FROM wrr$_replay_scn_order; 


done := (clock - min_scn) / (max_scn - min_scn); 

total_time := (systimestamp - start_time) / done; 


dbms_output.put_line('Estimated progression in replay: ' || 

to_char(100*done, '00') || '% done.'); 

dbms_output.put_line('Estimated time before completion: ' || 

((1 - done) * total_time)); 

dbms_output.put_line('Estimated total time for replay: ' || 

total_time); 

dbms_output.put_line('Estimated final time for replay: ' || 

to_char(start_time + total_time, 

'DD-MON-YY HH24:MI:SS')); 


END; 

/

Query to Provide Summary of Wait Events

--------------------------------------------------------------

--                           Query 3                        --

--------------------------------------------------------------- 


column event format a40 

select event, count(*), min(wait_for_scn) 

from gv$workload_replay_thread 

where session_type = 'REPLAY' 

group by event;

During replay, any error and data discrepancies between the replay system and the capture system are recorded as diverged calls. The DBMS_WORKLOAD_REPLAY.GET_DIVERGING_STATEMENT function retrieves information about a diverging call, including the statement text, the SQL ID and the binds.


Example usage

sqlplus / as sysdba


set long 30000000 longchunksize 1000 serverout on

ACCEPT ls_replay_id PROMPT 'Replay Id: '


DECLARE

r CLOB;

ls_stream_id NUMBER;

ls_call_counter NUMBER;

ls_sql_cd VARCHAR2(20);

ls_sql_err VARCHAR2(512);

CURSOR c IS

SELECT stream_id,call_counter

FROM DBA_WORKLOAD_REPLAY_DIVERGENCE

WHERE replay_id = &ls_replay_id;

BEGIN

OPEN c;

LOOP

FETCH c INTO ls_stream_id, ls_call_counter;

EXIT when c%notfound;

DBMS_OUTPUT.PUT_LINE (ls_stream_id||''||ls_call_counter);

r:=DBMS_WORKLOAD_REPLAY.GET_DIVERGING_STATEMENT(replay_id => &ls_replay_id,

stream_id => ls_stream_id, call_counter => ls_call_counter);

DBMS_OUTPUT.PUT_LINE (r);

END LOOP;

END;

/


Use the following for detailed set of information –


Comprehensive Database Real Application Testing Diagnostic Information (Doc ID 1287620.1)









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


as part of LTF suggested to use index Hint passed in query and as part of STF provided sql profiles for both the problematic sql


INC2222742(prem)



https://shivamoraclecloud.wordpress.com/2016/05/08/enq-tx-row-lock-contention/ ---enq:tx row lock contention


select * from table(dbms_xplan.display_awr('76bk7bjxkxu0y',format =>'outline')) ---- To check outline


select * from table(dbms_xplan.display_cursor('76bk7bjxkxu0y',format =>'outline')) ---- To check outline


DB: DMPROD

Schema : XXCQO_APPS

API NAME : XXCQO_APPS.XXMDM_REARCH_PKG.GET_DECOUPLE_DEAL_CONT__PR

PKG : XXMDM_REARCH_PKG

Procedure : GET_DECOUPLE_DEAL_CONT__PR


select * from dba_objects

where object_name like '%XXMDM_REARCH_PKG%'


select * from dba_objects

where object_id =2191580


SELECT*

FROM xxcpf_pm_sqlarea

WHERE sql_id='1039552910'

ORDER BY TRUNC (snap_date_time) DESC


Procedure body line ID# and program_id=7407758

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


SELECT *

FROM xxcpf_pm_sqlarea

WHERE program_line# between 9399 and 11280 and program_id=7407758

ORDER BY TRUNC (snap_date_time) DESC;

 

-------------------------------------when program name given

select concurrent_program_id from apps.fnd_concurrent_programs_tl ctl where user_concurrent_program_name like '%Cisco AS Missing Timecard Notifications%';


*****************  https://dba.cisco.com/dba-portal/tools/performance-management/OTMPRD


Query to Finding sql id using SQL text :

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


select /*+parallel(32)*/* from dba_hist_sqltext where sql_text like '%DELETE%MTL_ITEM_CATEGORIES_INTERFACE%WHERE%INVENTORY_ITEM_ID%'


SELECT sql_id, hash_value, SUBSTR(sql_text,1,40) Text FROM gv$sql WHERE sql_text LIKE '%athena_flg%';


-------------------------------------------------------- To find Db links and Remote DB name

select * from dba_db_links where db_link = 'RAO_TO_CG1.CISCO.COM';



select * from dba_db_links  where db_link like '%XXCTS_XELUS_CTS%'

---------------------------------------------------------------------------------


Blocking sessionS :

------------------

At entire database level :


select sql_id , event ,current_obj#, count(*),BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL#

from gv$active_session_history where session_id =1699 and session_serial#=23868

group by sql_id , event,current_obj#,BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# order by 4 desc;


Wait events and Blocking sessions :( for particular snap ids )


SELECT sql_id,

EVENT,

CURRENT_OBJ#,

(SELECT object_name

FROM dba_objects

WHERE object_id = current_obj#)

AS objectname,

sql_opname,

sql_plan_operation,

sql_plan_options,

BLOCKING_SESSION,

BLOCKING_SESSION_SERIAL#,

COUNT (1)

FROM dba_hist_active_sess_history

WHERE sql_id= '4cgt922duhyqa' and snap_id between 143218 and 143236

GROUP BY sql_id,

EVENT,

CURRENT_OBJ#,

sql_opname,

sql_plan_operation,

sql_plan_options,

BLOCKING_SESSION,

BLOCKING_SESSION_SERIAL#

ORDER BY COUNT (*) DESC



++++++++++++++++

To check snapping is enabled or not :


select /*+ index(a PERF11I.XXCPF_PM_SNAPSHOT_N3)*/inst_id,max(snap_date_time) snap , sysdate from xxcpf_pm_snapshot a

where snap_date_time>sysdate-12

group by inst_id;


======


Hot Block/Object  :


Number of concurrent session’s access single block in an object is known as hot object.


RELATIVE_FNO OWNER SEGMENT_NAME SEGMENT_TYPE

94 QTCDATA CG1_RA_CUSTOMER_TRX_LINES_ALL TABLE



=============== To find Hot Blocks 

SELECT p1 "file#", p2 "block#", p3 "class#"

FROM gv$session_wait

WHERE event = 'read by other session';


SELECT p1 "file#", p2 "block#", p3 "wait class#"

FROM gv$session_wait

WHERE event = 'gc buffer busy acquire';


SELECT relative_fno, owner, segment_name, segment_type

FROM dba_extents

WHERE file_id = &file

AND &block BETWEEN block_id AND block_id + blocks - 1;


====================== Finding sql using object/index name

SELECT

      p.dbid, 

      p.sql_id, 

      P.OBJECT_OWNER  A_INDEX_OWNER, 

      p.object_name   A_INDEX_NAME, 

      p.options       A_INDEX_OPERATION, 

      COUNT(*) NR_EXEC 

 FROM dba_hist_sql_plan p 

WHERE p.object_name = '&1'

GROUP BY

      P.dbid, 

      P.sql_id, 

      P.OBJECT_OWNER, 

      p.object_name, 

      p.options;

 

11g Row source at Run Time 

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


  select m.sql_id ,m.sql_plan_hash_value ,p.id,

    rpad(' ',p.depth*2, ' ')||p.operation ||'   ' || p.options  operation,

    p.object_name object,

    p.cardinality card,

    p.cost cost,

    substr(m.status,1,4) status,

    m.output_rows

 from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

 and p.child_address=m.sql_child_address

 and p.plan_hash_value=m.sql_plan_hash_value

 and p.id=m.plan_line_id

 AND s.sid = 4011

 AND s.inst_id = 1

 AND substr(m.status,1,4)  = 'EXEC'

 AND s.inst_id = m.inst_id

 AND s.inst_id = p.inst_id

 and s.key = m.key

 order by id

************

select m.sql_id ,m.sql_plan_hash_value ,p.id,

rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation,

p.object_name object,

p.cardinality card,

p.cost cost,

substr(m.status,1,4) status,

m.output_rows

from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

and p.child_address=m.sql_child_address

and p.plan_hash_value=m.sql_plan_hash_value

and p.id=m.plan_line_id

-- AND s.sid = 5756

--AND s.inst_id = 1

AND s.sql_id = 'f4rgw5jmbr745'

-- AND substr(m.status,1,4) = 'EXEC'

and m.sql_exec_id= 33554471

AND s.inst_id = m.inst_id

AND s.inst_id = p.inst_id

and s.key = m.key

order by id


select sql_exec_id from gv$sql_plan_monitor where sql_id = '52bqv2n02htrg' order by output_rows desc


select * from gv$sql_plan_monitor where sql_id = '4yg4fbrdmc4z0' order by output_rows desc


select sql_exec_id from gv$sql_plan_monitor where sql_id = '52bqv2n02htrg' order by output_rows desc

*******************


select m.sql_id ,m.sql_plan_hash_value ,p.id,

rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation,

p.object_name object,

p.cardinality card,

p.cost cost,

substr(m.status,1,4) status,

m.output_rows

from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s

where p.sql_id=m.sql_id

and p.child_address=m.sql_child_address

and p.plan_hash_value=m.sql_plan_hash_value

and p.id=m.plan_line_id

-- AND s.sid = 5756

--AND s.inst_id = 1

AND s.sql_id = '1v5tbzxag189n'

AND substr(m.status,1,4) = 'EXEC'

AND s.inst_id = m.inst_id

AND s.inst_id = p.inst_id

and s.key = m.key

order by id

 

QUERY to find sid and serial # when we have Request 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


------------------------------------------------------------------------------------------------------------------------------------------

For I/O latency :

-----------------

with base_line as (

        select

                /*+ materialize */

                 snp.instance_number,

                snp.snap_id,

                to_char(snp.end_interval_time,'Mon-dd hh24:mi:ss')     end_time,

                time_waited_micro,

                total_waits,

                event_name 

        from

                dba_hist_snapshot       snp,

                dba_hist_system_event       sst

        where

                snp.dbid            = :db_id

        and     snp.instance_number =  :instance_number

        and     end_interval_time   between sysdate - 15 and sysdate

        /*                                                        */

        and     sst.dbid            = snp.dbid

        and     sst.instance_number = snp.instance_number

        and     sst.snap_id         = snp.snap_id

        and     sst.event_name       = 'db file sequential read'

        /*                                                        */

)

select   b1.instance_number, b1.snap_id ,

        b1.end_time             start_of_delta,

        ROUND( (b1.time_waited_micro - b2.time_waited_micro)/((b1.total_waits - b2.total_waits) *1000) , 2)    value

from

        base_line        b1,

        base_line        b2

where

        b2.snap_id = b1.snap_id + 1

        and b2.instance_number = b1.instance_number

order by

         b1.snap_id desc



******************* Different SQL for plan Hash Value 


SELECT /*+ index(q.INT$DBA_HIST_SQLSTAT.sql WRH$_SQLSTAT_INDEX) */

---TRUNC (s.end_interval_time) sample_end,

-----(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = q.plan_hash_value and hash_value!=0 and rownum=1) ||' '||

---(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = DBMS_UTILITY.SQLID_TO_SQLHASH (q.SQL_ID) and rownum=1) cases,

q.sql_id,

-- MIN (q.snap_id) min_snp,

-- MAX (q.snap_id) max_snp,

-- MAX (q.dbid) dbid,

q.plan_hash_value phv,

-- q.instance_number INST,

SUM (q.EXECUTIONS_DELTA) exs,

ROUND (SUM (ELAPSED_TIME_delta) / 1000 / 1000, 2) TOT_SEC,

-- SUM (q.parse_calls_DELTA) hard_parse,

-- SUM (q.version_count) version,

CEIL (

ROUND (

SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

1))

pio_pex,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

lio_pex,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_pex,

ROUND (

CEIL (

ROUND (

SUM (BUFFER_GETS_delta)

/ GREATEST (SUM (executions_delta), 1),

1))

/ GREATEST (

ROUND (

( SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1),

1),

2)

Lio_Row,

ROUND (

( SUM (IOWAIT_DELTA)

/ GREATEST (SUM (executions_delta), 1)

/ 1000000),

4)

IO_PEX,

ROUND (

( SUM (CPU_TIME_DELTA)

/ GREATEST (SUM (executions_delta), 1)

/ 1000000),

4)

CPU_PEX,

ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000

sec_PEX --,max(s.end_interval_time) last_snap_time

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE -----q.SQL_ID = TRIM ('&sql_id')

q.plan_hash_value=&plan_hash

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, --q.instance_number,

TRUNC (s.end_interval_time)

ORDER BY MAX (s.end_interval_time) DESC, q.sql_id, q.plan_hash_value;


pass sql id as 0

and plan hash value we have 


sample Output :

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


SQL_ID PHV EXS TOT_SEC PIO_PEX LIO_PEX ROWS_PEX LIO_ROW IO_PEX CPU_PEX SEC_PEX

4ng4ujpkj7mnb 1058250243 1 40.12 256897 545566 21 25979.33 8.7442 32.7442 40.1231

g03ta02ft0811 1058250243 1 46.38 257010 686160 20 34308 14.629 33.741 46.3802

8uy0vz07pwrsz 1058250243 1 42.49 256940 658344 20 32917.2 12.7455 31.801 42.492

 

 

To Check Object Owner  : -------> subrat 

----------------------

SELECT DISTINCT object_owner, object_name ,object_owner||'.'|| object_name

FROM dba_hist_sql_plan

WHERE sql_id = '8ud720mw1rkyk' AND plan_hash_value =3886700095

AND object_type IN

('VIEW (FIXED)',

'TABLE (TEMP)',

'MAT_VIEW',

'TABLE (FIXED)',

'VIEW',

'TABLE');


==========sessions and sql acting on same objects

select distinct(sql_id) from dba_hist_active_sess_history where current_obj#=-40001599 and snap_id between 149383 and 149394

select distinct(sessio_id) from dba_hist_active_sess_history where current_obj#=-40001599 and snap_id between 149383 and 149394

=========


Analysis :

Cause

Bug 12701301 - WAIT CLASSE: OTHER OJVM : GENERIC was opened for this issue.

It was closed as duplicate of :

Bug 10325230 - RUNTIME.EXEC CAN HANG WHEN USED WITH RESOURCE MANAGER ACTIVE


Solution

Bug 10325230 will be fixed in 12.1, so currently the following options are available to solve this issue.



1. The workaround from bug 12701301:

'The issue only reproduces if resource_manager_plan ='DEFAULT_MAINTENANCE_PLAN'. If resource_manager_plan is not set, then the operation completes.'


2. The workaround from bug 10325230:

'Don't use user threads to read from Process streams, or don't use them

when RM is active, or use Thread.stop or other mechanisms to actively

stop/kill the threads once the related Process has exited.'


3. Apply a patch for bug 10325230. Patches can be requested only for 11.2.0.2.0 and later. Affected code did not exist before that.

Just got of the phone with my buddies at oracle

This is the workaround to fix the same

Ideally you should not be hitting this wait as PDBPROD is currently on 19c release

This issue was fixed by Oracle Bug Diagnostics group in 12.1.0.2 release

Cheers

🙂

Josh Arora Friday, 11:08 PM


The parameter has been set to FORCE hence the issue -

Connected to:

Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.10.0.0.0


SQL> def

DEFINE _DATE = "20-AUG-2021" (CHAR)

DEFINE _CONNECT_IDENTIFIER = "PDBPROD1" (CHAR)

DEFINE _USER = "PERF11I" (CHAR)

DEFINE _PRIVILEGE = "" (CHAR)

DEFINE _SQLPLUS_RELEASE = "1910000000" (CHAR)

DEFINE _EDITOR = "vi" (CHAR)

DEFINE _O_VERSION = "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Version 19.10.0.0.0" (CHAR)

DEFINE _O_RELEASE = "1910000000" (CHAR)

SQL> set time on

10:34:47 SQL> set pages 50000 lines 1000 trimsp on

10:34:54 SQL> show parameter resource_manager_plan


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

resource_manager_plan string FORCE:XXCMR_APPDB_TOP_PLAN

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

resource_manager_plan string FORCE:XXCMR_APPDB_TOP_PLAN <<< There is no default value >>> for this parameter in oracle






https://oracledbaarena.blogspot.com/2021/08/troubleshooting-oracle-long-running.html


https://oracledbaarena.blogspot.com/2021/06/oracle-long-running-query-performance.html


Step:1: when request id given to find sid



SELECT a.request_id,

       a.status_code,

       a.phase_code,

       a.actual_start_date,

       a.actual_completion_date,

       a.completion_text,

       s.sid,

       s.serial#,

       s.osuser,

       s.process,

       c.spid

FROM   apps.fnd_concurrent_requests a,

       apps.fnd_concurrent_processes b,

       gv$process c,

       gv$session s

WHERE  a.controlling_manager = b.concurrent_process_id

       AND c.pid = b.oracle_process_id

       AND b.session_id = s.audsid

       AND a.request_id = &request_id

       ---AND a.phase_code = 'R'; 

   

Lock Query :


CLEAR COLUMNS

col ssid    form A7

col lmode   form 999 heading "loc"

col request form 999 heading "req"

col name    form A30

break on id1 on sid

select lpad(' ',decode(a.request,0,0,3))||a.sid ssid,

       a.id1,

       a.lmode,

       a.request,

       c.name

  from sys.obj$  c,

       gv$lock    b,

       gv$lock    a

 where a.id1 in ( select id1 from gv$lock where lmode = 0 )

   and a.sid  = b.sid

   and c.obj# = b.id1

   and b.type = 'TM'

 order by a.id1, a.request, b.sid, c.name

Block Query :


SELECT blocking_session,

       sid

FROM   v$session

WHERE  blocking_session != 0; 


select * from apps.fnd_concurrent_requests where request_id = 447652808


select * FROM apps.fnd_concurrent_requests fr

WHERE fr.concurrent_program_id = 194649

AND fr.phase_code IN ( 'R')


select request_id,requested_start_date, actuaL_start_date, actual_completion_date,parent_request_id ,round((actual_completion_date-actual_start_date)*24*60*60,2) time

from apps.fnd_concurrent_requests where Concurrent_program_id= 194649 order by actuaL_start_date desc ;


select REQUEST_ID,REQUEST_DATE,PHASE_CODE,STATUS_CODE,ACTUAL_START_DATE,ACTUAL_COMPLETION_DATE,COMPLETION_TEXT from apps.fnd_concurrent_requests where request_id = 1095666418


select * from apps.fnd_concurrent_requests where request_id in ('447652808')


select * from apps.fnd_concurrent_requests where parent_request_id in ('447652808')


select * from xxcpf_pm_snapshot where request_id ='472915457'

order by snap_date_time desc




select * from gv$sql where sql_id='5xdtmvsyzcncf';


select * from gv$sqlarea where sql_id='5xdtmvsyzcncf';


check status R/C Runing ----> SHOWING Runing


--------------------------------------------

select max(snap_date_time) from xxcpf_pm_snapshot


select * from xxcpf_pm_snapshot where request_id ='472915457'

order by snap_date_time desc



select * from xxcpf_pm_snapshot where sql_id='5xdtmvsyzcncf'

order by snap_date_time desc  

-----1039552910 ----SQL_HASh_VALUE



SELECT*

FROM xxcpf_pm_sqlarea

WHERE sql_hash =1039552910

ORDER BY TRUNC (snap_date_time) DESC

------2191580 PROG ID  



select * from dba_objects

where object_id =2191580



select * from xxcpf_pm_snapshot where request_id in (452058932, 452058907)

order by snap_date_time desc -----> To find sid serial #


----gv$session ----(active/inactive)

----gv$active_session_history(ash ) -----

----Dba_active_history(awr ) ----- 


************** if snapping is not enabled


select sql_id, count(*), user_id,current_obj#

from dba_hist_active_sess_history

where sample_time >= TIMESTAMP '2020-04-01 04:40:00' AND sample_time < TIMESTAMP '2020-04-03 10:30:00'

and event_id = 2952162927

group by sql_id, user_id, current_obj#

order by 2 desc

/



**************************



select * from xxcpf_pm_snapshot where request_id in(534527861,

534527862,

534527863,

534527864,

534527865,

534527866,

534527867,

534527868,

534527869,

534527870,

534527871,

534527857,

534527858,

534527859,

534527860)

order by snap_date_time desc;

-------------------------------------------------------------------------------------------

TO find Dependent Sql :


select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE

from dba_hist_active_sess_history ash

where ----ash.session_id =356--261--3784-- 1407

---and ash.session_serial# =51384--36841-- 27977--43531

--and ash.instance_number =1--1--1--5

top_level_sql_id='724bs6hgzyahx' and sql_id<>'724bs6hgzyahx'

group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc


=============TO find Dependent/underlying Sql

select /*+ index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*)

from dba_hist_active_sess_history ash

where ash.snap_id between 76892 and 76917

and dbid = (select dbid from v$database)

and top_level_sql_id='a1g4r29fpwh7w'

and sql_id != 'a1g4r29fpwh7w'

group by ash.sql_id order by count(*) desc;



------------- To find sql acting on current object


select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ session_id, session_serial#,ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE

from dba_hist_active_sess_history ash

where current_obj#=1417408 and snap_id between 52290 and 52293

group by session_id, session_serial#,ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 4 desc


================ finding serial # using sid 


select inst_id,SID,serial#,username from gv$session_longops where SID='4105';


-- select inst_id,SID,serial#,username from gv$session_longops;


select * from gv$session where sid=3350 and serial#=17337


++++++++++++++++++++++++ when particular time stamp mentioned 


Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from gv$active_session_history where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and 

'27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20;


Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from dba_hist_active_sess_history where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and 

'27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20;



Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from gv$session where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and 

'27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20;

-------

step:1: To find Top SQL


select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE

from dba_hist_active_sess_history ash

where ash.session_id =356--261--3784-- 1407

and ash.session_serial# =51384--36841-- 27977--43531

--and ash.instance_number =1--1--1--5

--and top_level_sql_id='5xdtmvsyzcncf'

group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc


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

select to_char(sql_exec_start, 'dd-Mon hh24:mi'), elapsed_time, cpu_time

from   gv$sql_monitor

where  sql_id = '2g2w2cbx5zjy8';


TO_CHAR(SQL_EXEC_START,'DD-MONHH24:MI')  ELAPSED_TIME   CPU_TIME

14-Sep 03:46                            4399447919       431044146



=============== to find object name for snap id and sql id 


select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,(SELECT object_name

FROM dba_objects

WHERE object_id = current_obj#)

AS objectname,SQL_PLAN_HASH_VALUE

from dba_hist_active_sess_history ash

where snap_id between 161923 and 161964 

and sql_id='faukwp097vwt6'

---ash.session_id =--261--3784-- 1407

--and ash.session_serial# =--36841-- 27977--43531

--and ash.instance_number =1--1--1--5

--and top_level_sql_id='5xdtmvsyzcncf'

group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc


==========

select sql_id , event ,current_obj#, count(*),BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL#

from gv$active_session_history where session_id =802 and session_serial#=4081

group by sql_id , event,current_obj#,BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# order by 4 desc;


select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from gv$session_longops where SID='7924';


select * from gv$session where sid= and serial#=


select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE

from dba_hist_active_sess_history ash

where ash.session_id =3926--261--3784-- 1407

and ash.session_serial# =42259--36841-- 27977--43531

and ash.instance_number =1--1--1--5

--and top_level_sql_id='5xdtmvsyzcncf'

group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc


--------------------------------------------------------------------------  for LOB issues 

SELECT * FROM DBA_LOBS WHERE OWNER = 'PXP_ADMIN' AND SEGMENT_NAME= 'SYS_LOB0066169541C00001$$' ;

SELECT SUM(DBMS_LOB.GETLENGTH(CONTENT))/1024/1024/1024 SIZEGB FROM TABLE_NAME;



SELECT SUM(DBMS_LOB.GETLENGTH(CONTENT))/1024/1024/1024 SIZEGB FROM TABLE_NAME;


SELECT * FROM DBA_LOBS WHERE SEGMENT_NAME LIKE '%SYS_LOB0066169541C00001$$%'



SELECT SEGMENT_NAME,BYTES/1024/1024/1024 SizeGB FROM DBA_SEGMENTS WHERE OWNER='PXP_ADMIN' AND SEGMENT_NAME='SYS_LOB0066169541C00001$$' ORDER BY BYTES DESC



SELECT SUM(DBMS_LOB.GETLENGTH("FILE_DATA"))/1024/1024/1024 SIZEGB FROM APPS.FND_LOBS; -- SIZEGB 742.084746874869


select round(bytes/1024/1024/1024,2) SIZEGB, a.* from dba_segments a where segment_name ='' and owner ='' -- 1239.283203125


SELECT * FROM DBA_LOBS WHERE OWNER = '' AND SEGMENT_NAME= '' ;



SELECT * FROM dba_EXTENTS where segment_name =''


SELECT SUM(DBMS_LOB.GETLENGTH("BE_GEO_QUAL_JSON"))/1024/1024/1024 SIZEGB FROM PXP_ADMIN.PXP_BE_GEO_QUAL_JSON_MV;

BE_GEO_QUAL_JSON--- column nmae 

(schema.table name )


select count(*) from PXP_ADMIN.PXP_BE_GEO_QUAL_JSON_MV;


COUNT(*)

136549


TO find size of LOB :

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


select

   table_name,

   column_name,

   segment_name,

   a.bytes

from

   dba_segments a

join

   dba_lobs b

using (owner, segment_name)

where

   b.table_name = 'PXP_BE_GEO_QUAL_JSON_MV';

   

O/p as follows :


TABLE_NAME COLUMN_NAME SEGMENT_NAME BYTES

PXP_BE_GEO_QUAL_JSON_MV BE_GEO_QUAL_JSON SYS_LOB0066169541C00001$$ 790626304


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

select '''' || ash.sql_id || '''' || ',', count(*) 

from dba_hist_active_sess_history ash, (SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid

   FROM dba_hist_snapshot

  WHERE TRUNC (begin_interval_time) <= TO_DATE ('11-FEB-2020', 'DD-MON-YYYY')

GROUP BY dbid) snap

where ash.snap_id >= snap.min_snap_id and snap_id <= snap.max_snap_id and snap.dbid = ash.dbid

and ash.session_id =1754

and ash.session_serial# =9365

---and ash.instance_number = ----1 ----6

group by  '''' || ash.sql_id || '''' || ',' order by 2 desc;


---------------



SQL> select inst_id,sid,serial#,blocking_session,blocking_instance,sql_id,username,event,program,machine,p1,p2,last_call_et/60 from gv$session where sid=5712 and inst_id=1 ;


INST_ID SID SERIAL# BLOCKING_SESSION BLOCKING_INSTANCE SQL_ID USERNAME EVENT PROGRAM MACHINE P1 P2 LAST_CALL_ET/60

---------- ---------- ---------- ---------------- ----------------- ------------- ------------------------------ ---------------------------------------------------------------- ------------------------------------------------ ---------------------------------------------------------------- ---------- ---------- ---------------

1 5712 24074 dyj43q7nhq91z APPS db file parallel read JDBC Thin Client c7-a1-oa2-iprd-200 1 2 204.916667



+++++++++++++++++++++++++++++++++  To check Temp usage 


SET PAGES 999

SET LINES 300

COL USERNAME FOR A10

COL SID FOR 99999

COL PID FOR A5

COL STATUS FOR A8

COL SQL_ID FOR A13

COL EVENT FOR A30

COL CONNNECTED_FROM FOR A22

COL TABLESPACE FOR A10

COL SEGTYPE FOR A10

SELECT * FROM TEMP_USAGE WHERE STATUS='ACTIVE' AND TEMP_USED_GB>0;





select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig

from DBA_HIST_ACTIVE_SESS_HISTORY

where

sample_time > sysdate-1 and

TEMP_SPACE_ALLOCATED > (50*1024*1024*1024)

group by sql_id order by 2;




SQL_ID GIG

------------- ----------

f8v7xup2hg4b3 68.09375

bgtyc6t6pavkm 88.3623047

d2n11pf319wg6 94.8876953 <<< Problem SQL_ID >>>


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



SELECT a.sid,

       RPAD (a.opname, 30),

       a.sofar,

       a.totalwork,

       a.ELAPSED_SECONDS,

       ROUND ( ( (a.sofar) * 100) / a.totalwork, 3) "%_COMPLETED",

       time_remaining,

       RPAD (a.username, 10) username,

       a.SQL_HASH_VALUE,

       B.STATUS

  FROM GV$SESSION_LONGOPS a, gv$session b

 WHERE a.sid = &sid AND b.inst_id = &inst_id AND b.serial# = &serial AND a.sofar <> a.totalwork

/



Gettting SQL_TEXT if we have SQL_id(5xdtmvsyzcncf) :

---------------------------------------------------

------> click on Huge LOB


DBID SQL_ID COMMAND_TYPE CON_DBID CON_ID

1,567,590,801 5xdtmvsyzcncf 2 1,567,590,801 0


Query to find SQL text :

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


select * from DBA_HIST_SQLTEXT where sql_id='2k8z7fpqjbvdp'



select * from gv$sql where sql_id='52bqv2n02htrg';



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


Find Long Running Sessions

/*************************************************************************

Check the ALL Active/Inactive session

**************************************************************************/


set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER'

 order by logon_time;


/*************************************************************************

Check the all Active session

**************************************************************************/


set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER' and b.status='ACTIVE'

 order by logon_time;

 

For parallel session :

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


col username for a12

col "QC SID" for A6

col SID for A6

col "QC/Slave" for A10

col "Requested DOP" for 9999

col "Actual DOP" for 9999

col "slave set" for  A10

set pages 100


select

  decode(px.qcinst_id,NULL,username,

        ' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username",

  decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" ,

  to_char( px.server_set) "Slave Set",

  to_char(s.sid) "SID",

  decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID",

  px.req_degree "Requested DOP",

  px.degree "Actual DOP"

from

  gv$px_session px,

  gv$session s

where

  px.sid=s.sid (+)

 and

  px.serial#=s.serial#

order by 5 , 1 desc

/

 

/*************************************************************************

Check the ALL Active/Inactive sessions by machine name 

**************************************************************************/

 

set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER' and b.machine='&machine'

-- and b.status='ACTIVE'

-- and b.status='INACTIVE'

 order by logon_time;



/*************************************************************************

Check the ALL Active/Inactive sessions by SID

**************************************************************************/


set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER' and b.SID='&SID'

-- and b.status='ACTIVE'

-- and b.status='INACTIVE'

 order by logon_time;


/*************************************************************************

Check the ALL Active/Inactive sessions by Username

**************************************************************************/


set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER' and b.username='&username'

-- and b.status='ACTIVE'

-- and b.status='INACTIVE'

 order by logon_time;



When SQL is Running :

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


SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME,

SQL_ID,

PLAN_HASH_VALUE,

SUM (EXECUTIONS) EXECUTIONS,

ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC,

ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1)

PIO_PER_EXEC,

ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1)

LIO_PER_EXEC,

ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)

ROWS_PER_EXEC,

ROUND (

(SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1))

/ GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1),

1),

1)

lio_per_row,

ROUND (

(SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1),

1)

|| 'ms/'

|| ROUND (

(SUM (ELAPSED_TIME) / 1000 / 1000)

/ GREATEST (SUM (EXECUTIONS), 1),

2)

|| 'sec/'

|| ROUND (

(SUM (ELAPSED_TIME) / 1000 / 1000 / 60)

/ GREATEST (SUM (EXECUTIONS), 1),

1)

|| 'min'

TIME_PER_EXEC,

MAX (sql_profile) sqlprofile

FROM GV$SQL

WHERE SQL_ID = '&sql_id'

GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME)

ORDER BY 1 DESC;


To check History and sql proile picking or not :

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


SELECT s.end_interval_time sample_end,

MIN (q.snap_id) min_snapid,

MAX (q.snap_id) max_snapid,

q.sql_id,

q.plan_hash_value PHV,

SUM (q.EXECUTIONS_DELTA) exec,

SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

SUM (q.parse_calls_DELTA) HParse,

SUM (q.version_count) vers,

CEIL (

ROUND (

SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

1))

pio_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

lio_exec,

ROUND (

(SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

IO_Wait,

ROUND (

(SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

CPU_Wait,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

/ DECODE (

TRUNC(ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1)),

0, 1,

ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1))

LIO_PER_ROW,

ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ (1000 * 60)),

4)

|| 'M'

exec_time,

(SELECT (SELECT reference

FROM xxcpf_pm_sql_statement_fix

WHERE ROWNUM = 1

AND (hash_value = q.plan_hash_value

OR hash_value =

(SELECT DBMS_UTILITY.

SQLID_TO_SQLHASH (q.sql_id)

FROM DUAL)))

FROM DUAL)

defect_id,

parsing_schema_name,max(sql_profile)

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE q.SQL_ID = TRIM ('&sql_id')

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, s.end_interval_time,parsing_schema_name

ORDER BY 1 DESC, q.sql_id, q.plan_hash_value;


*************


Queries to get 12C and 19 C Plans :

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


SELECT ( LPAD (' ', 2 * (DEPTH - 1))

|| ' '

|| DEPTH

|| ' '

|| operation

|| ' '

|| options

|| ' '

|| object_name

|| ' '

|| DECODE (access_predicates,

NULL, NULL,

'access_predicates =' || access_predicates)

|| ' '

|| DECODE (filter_predicates,

NULL, NULL,

'filter_predicates = ' || filter_predicates)

|| ' '

|| PARTITION_START

|| '-'

|| PARTITION_STOP

|| ' (Cost ='

|| COST

|| ' '

|| 'Card = '

|| CARDINALITY

|| ' Bytes ='

|| bytes

|| ')')

Ex_Plan

FROM (SELECT *

FROM (SELECT DISTINCT

operation,

options,

object_name,

access_predicates,

filter_predicates,

COST,

CARDINALITY,

BYTES,

ID,

PARTITION_STOP,

PARTITION_START,

DEPTH,

ROW_NUMBER ()

OVER (PARTITION BY ID ORDER BY COST DESC)

rnk

FROM xxcpf_pm_sql_plan

WHERE plan_hash = &&plan_hash)

WHERE rnk = 1)

ORDER BY id;




Suraj Ramchander 5/27/2022, 3:47 PM



/*+ opt_param('_optimizer_cbqt_or_expansion','off')*/

Suraj Ramchander 5/27/2022, 4:14 PM


SELECT snap_date_time,

sql_id,

plan_hash,

executions,

ROUND (load_duration * 24 * 60 * 60, 2) total_secs,

CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1))

pio_per_exec,

CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

lio_per_exec,

ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1)

Rows_per_exec,

ROUND (

CEIL (

ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

/ GREATEST (

ROUND (

(SUM (rows_processed) / GREATEST (SUM (executions), 1)),

1),

1),

2)

LIO_PER_ROW,

ROUND (

( (load_duration / GREATEST (SUM (executions), 1))

* 24

* 60

* 60),

2)

|| 'sec/'

|| ROUND (

( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60),

2)

|| 'min'

Time_per_Exec

FROM xxcpf_pm_sqlarea

WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash)

GROUP BY sql_id,

plan_hash,

executions,

buffer_gets,

disk_reads,

executions,

snap_date_time,

load_duration

ORDER BY snap_date_time DESC;

Suraj Ramchander 5/27/2022, 4:31 PM


Sent out the mail with 19c top SQLs from ASH (TS3CG1)

Suraj Ramchander

SELECT snap_date_time,

sql_id,

plan_hash,

executions,

ROUND (load_duration * 24 * 60 * 60, 2) total_secs,

CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1))

pio_per_exec,

CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

lio_per_exec,

ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1)

Rows_per_exec,

ROUND (

CEIL (

ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

/ GREATEST (

ROUND (

(SUM (rows_processed) / GREATEST (SUM (executions), 1)),

1),

1),

2)

LIO_PER_ROW,

ROUND (

( (load_duration / GREATEST (SUM (executions), 1))

* 24

* 60

* 60),

2)

|| 'sec/'

|| ROUND (

( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60),

2)

|| 'min'

Time_per_Exec

FROM xxcpf_pm_sqlarea

WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash)

GROUP BY sql_id,

plan_hash,

executions,

buffer_gets,

disk_reads,

executions,

snap_date_time,

load_duration

ORDER BY snap_date_time DESC;



PLease use this if data is unavailable in dba_hist....and 12c executions can be checked in CG1PRD also if unavailable in TS3



Query to check whether SQL is progressing or hanged :

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


column plan_line_id format 9999 heading 'LINE'

column plan_options format a10 heading 'OPTIONS'

column status format a10

column output_rows heading 'ROWS'

break on sid on sql_id on status

SELECT sid, sql_id, status, plan_line_id,

plan_operation || ' ' || plan_options operation, output_rows

FROM gv$sql_plan_monitor

WHERE status not like '%DONE%' and sid='&sid' 

ORDER BY 1,4;


or


column plan_line_id format 9999 heading 'LINE'

column plan_options format a10 heading 'OPTIONS'

column status format a10

column output_rows heading 'ROWS'

break on sid on sql_id on status

SELECT sid, sql_id, status, plan_line_id,

plan_operation || ' ' || plan_options operation, output_rows

FROM v$sql_plan_monitor

WHERE status not like '%DONE%'

ORDER BY 1,4;



       SID SQL_ID        STATUS      LINE OPERATION                       ROWS

---------- ------------- ---------- ----- ------------------------- ----------

        24 5mxdwvuf9j3vp EXECUTING      0 SELECT STATEMENT                   0

                                        1 SORT AGGREGATE                     0

                                        2 NESTED LOOPS                      10

                                        3 PARTITION RANGE ALL            23794 <-- see diff

                                        4 TABLE ACCESS FULL              23794 <-- see diff

                                        5 TABLE ACCESS FULL                 10

        27 5mxdwvuf9j3vp EXECUTING      0 SELECT STATEMENT                   0

                                        1 SORT AGGREGATE                     0

                                        2 NESTED LOOPS                      10

                                        3 PARTITION RANGE ALL            23861 <--- see diff

                                        4 TABLE ACCESS FULL              23861 <--- see diff

                                        5 TABLE ACCESS FULL                 10


12 rows selected.


SQL>


We can see the difference. Hence the query is not hanged


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


To check the Historic Plan :

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


set lines 1000 pages 9999

COL instance_number FOR 9999 HEA 'Inst';

COL end_time HEA 'End Time';

COL plan_hash_value HEA 'Plan|Hash Value';

COL executions_total FOR 999,999 HEA 'Execs|Total';

COL rows_per_exec HEA 'Rows Per Exec';

COL et_secs_per_exec HEA 'Elap Secs|Per Exec';

COL cpu_secs_per_exec HEA 'CPU Secs|Per Exec';

COL io_secs_per_exec HEA 'IO Secs|Per Exec';

COL cl_secs_per_exec HEA 'Clus Secs|Per Exec';

COL ap_secs_per_exec HEA 'App Secs|Per Exec';

COL cc_secs_per_exec HEA 'Conc Secs|Per Exec';

COL pl_secs_per_exec HEA 'PLSQL Secs|Per Exec';

COL ja_secs_per_exec HEA 'Java Secs|Per Exec';

SELECT 'gv$dba_hist_sqlstat' source,h.instance_number,

       TO_CHAR(CAST(s.begin_interval_time AS DATE), 'DD-MM-YYYY HH24:MI') snap_time,

       TO_CHAR(CAST(s.end_interval_time AS DATE), 'DD-MM-YYYY HH24:MI') end_time,

       h.sql_id,

       h.plan_hash_value, 

       h.executions_total,

       TO_CHAR(ROUND(h.rows_processed_total / h.executions_total), '999,999,999,999') rows_per_exec,

       TO_CHAR(ROUND(h.elapsed_time_total / h.executions_total / 1e6, 3), '999,990.000') et_secs_per_exec,

       TO_CHAR(ROUND(h.cpu_time_total / h.executions_total / 1e6, 3), '999,990.000') cpu_secs_per_exec,

       TO_CHAR(ROUND(h.iowait_total / h.executions_total / 1e6, 3), '999,990.000') io_secs_per_exec,

       TO_CHAR(ROUND(h.clwait_total / h.executions_total / 1e6, 3), '999,990.000') cl_secs_per_exec,

       TO_CHAR(ROUND(h.apwait_total / h.executions_total / 1e6, 3), '999,990.000') ap_secs_per_exec,

       TO_CHAR(ROUND(h.ccwait_total / h.executions_total / 1e6, 3), '999,990.000') cc_secs_per_exec,

       TO_CHAR(ROUND(h.plsexec_time_total / h.executions_total / 1e6, 3), '999,990.000') pl_secs_per_exec,

       TO_CHAR(ROUND(h.javexec_time_total / h.executions_total / 1e6, 3), '999,990.000') ja_secs_per_exec

  FROM dba_hist_sqlstat h, 

       dba_hist_snapshot s

 WHERE h.sql_id = '&sql_id'

   AND h.executions_total > 0 

   AND s.snap_id = h.snap_id

   AND s.dbid = h.dbid

   AND s.instance_number = h.instance_number

UNION ALL  

SELECT 'gv$sqlarea_plan_hash' source,h.inst_id, 

       TO_CHAR(sysdate, 'DD-MM-YYYY HH24:MI') snap_time,

       TO_CHAR(sysdate, 'DD-MM-YYYY HH24:MI') end_time,

       h.sql_id,

       h.plan_hash_value, 

       h.executions,

       TO_CHAR(ROUND(h.rows_processed / h.executions), '999,999,999,999') rows_per_exec,

       TO_CHAR(ROUND(h.elapsed_time / h.executions / 1e6, 3), '999,990.000') et_secs_per_exec,

       TO_CHAR(ROUND(h.cpu_time / h.executions / 1e6, 3), '999,990.000') cpu_secs_per_exec,

       TO_CHAR(ROUND(h.USER_IO_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') io_secs_per_exec,

       TO_CHAR(ROUND(h.CLUSTER_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') cl_secs_per_exec,

       TO_CHAR(ROUND(h.APPLICATION_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') ap_secs_per_exec,

       TO_CHAR(ROUND(h.CLUSTER_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') cc_secs_per_exec,

       TO_CHAR(ROUND(h.PLSQL_EXEC_TIME / h.executions / 1e6, 3), '999,990.000') pl_secs_per_exec,

       TO_CHAR(ROUND(h.JAVA_EXEC_TIME / h.executions / 1e6, 3), '999,990.000') ja_secs_per_exec

  FROM gv$sqlarea_plan_hash h 

 WHERE h.sql_id = '&sql_id'

   AND h.executions > 0 

order by source ;




Step:2:  Give sql_id find plan hash value(2202985026/3268999420/2538825766/1810801894)

-------


SELECT TRUNC (s.end_interval_time) sample_end,

MIN (q.snap_id) min_snapid,

MAX (q.snap_id) max_snapid,

q.sql_id,

q.plan_hash_value PHV,

SUM (q.EXECUTIONS_DELTA) exec,

SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

SUM (q.parse_calls_DELTA) HParse,

SUM (q.version_count) vers,

CEIL (

ROUND (

SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

1))

pio_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

lio_exec,

ROUND (

(SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

IO_Wait,

ROUND (

(SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

CPU_Wait,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

/ DECODE (

TRUNC(ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1)),

0, 1,

ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1))

LIO_PER_ROW,

ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ (1000 * 60)),

4)

|| 'M'

exec_time,

(SELECT (SELECT reference

FROM xxcpf_pm_sql_statement_fix

WHERE ROWNUM = 1

AND (hash_value = q.plan_hash_value

OR hash_value =

(SELECT DBMS_UTILITY.

SQLID_TO_SQLHASH (q.sql_id)

FROM DUAL)))

FROM DUAL)

defect_id,

parsing_schema_name

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE q.SQL_ID = TRIM ('&sql_id')

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time),parsing_schema_name

ORDER BY 1 DESC, q.sql_id, q.plan_hash_value;



=================== Online Monitoring


SET LINESIZE 2000

SET PAGESIZE 5000

COL TABLE_NAME FORMAT A30

COL NUM_ROWS FORMAT A10

SET FEEDBACK OFF

col cases FORMAT a20

COL PCT_ANALYZED FORMAT A15

COL LAST_ANALYZED FORMAT A20

COL USED_BLOCKS FORMAT A15

COL BLOCKS FORMAT A15

set verify off




SELECT /*+ index(q.INT$DBA_HIST_SQLSTAT.sql WRH$_SQLSTAT_INDEX) */

TRUNC (s.end_interval_time) sample_end,

(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = q.plan_hash_value and hash_value!=0 and rownum=1) ||' '||

(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = DBMS_UTILITY.SQLID_TO_SQLHASH (q.SQL_ID) and rownum=1) cases,

q.sql_id,

-- MIN (q.snap_id) min_snp,

-- MAX (q.snap_id) max_snp,

-- MAX (q.dbid) dbid,

q.plan_hash_value phv,

-- q.instance_number INST,

SUM (q.EXECUTIONS_DELTA) exs,

ROUND (SUM (ELAPSED_TIME_delta) / 1000 / 1000, 2) TOT_SEC,

-- SUM (q.parse_calls_DELTA) hard_parse,

-- SUM (q.version_count) version,

CEIL (

ROUND (

SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

1))

pio_pex,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

lio_pex,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_pex,

ROUND (

CEIL (

ROUND (

SUM (BUFFER_GETS_delta)

/ GREATEST (SUM (executions_delta), 1),

1))

/ GREATEST (

ROUND (

( SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1),

1),

2)

Lio_Row,

ROUND (

( SUM (IOWAIT_DELTA)

/ GREATEST (SUM (executions_delta), 1)

/ 1000000),

4)

IO_PEX,

ROUND (

( SUM (CPU_TIME_DELTA)

/ GREATEST (SUM (executions_delta), 1)

/ 1000000),

4)

CPU_PEX,

ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000

sec_PEX --,max(s.end_interval_time) last_snap_time

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE q.SQL_ID = TRIM ('&sql_id')

--q.plan_hash_value=&plan_hash

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, --q.instance_number,

TRUNC (s.end_interval_time)

ORDER BY MAX (s.end_interval_time) DESC, q.sql_id, q.plan_hash_value;


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

V$sql_shared_cursor , multiple version reasons  --- Reason for plan change

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


select

 sql_id,count(*) total_version,''

 ||decode(max(                UNBOUND_CURSOR),'Y',               ' UNBOUND_CURSOR'      ||'( '||SUM(DECODE(      UNBOUND_CURSOR,'Y',1,0))||')' )

 ||decode(max(             SQL_TYPE_MISMATCH),'Y',            ' SQL_TYPE_MISMATCH'       ||'( '||SUM(DECODE(   SQL_TYPE_MISMATCH,'Y',1,0))||')' )

 ||decode(max(            OPTIMIZER_MISMATCH),'Y',           ' OPTIMIZER_MISMATCH'       ||'( '||SUM(DECODE(  OPTIMIZER_MISMATCH,'Y',1,0))||')')

 ||decode(max(              OUTLINE_MISMATCH),'Y',             ' OUTLINE_MISMATCH'       ||'( '||SUM(DECODE(    OUTLINE_MISMATCH,'Y',1,0))||')')

 ||decode(max(            STATS_ROW_MISMATCH),'Y',           ' STATS_ROW_MISMATCH'       ||'( '||SUM(DECODE(  STATS_ROW_MISMATCH,'Y',1,0))||')')

 ||decode(max(              LITERAL_MISMATCH),'Y',             ' LITERAL_MISMATCH'       ||'( '||SUM(DECODE(    LITERAL_MISMATCH,'Y',1,0))||')')

-- ||decode(max(            SEC_DEPTH_MISMATCH),'Y',           ' SEC_DEPTH_MISMATCH'     ||'( '||SUM(DECODE(    SEC_DEPTH_MISMATCH,'Y',1,0))||''

 ||decode(max(           EXPLAIN_PLAN_CURSOR),'Y',          ' EXPLAIN_PLAN_CURSOR'       ||'( '||SUM(DECODE( EXPLAIN_PLAN_CURSOR,'Y',1,0))||')')

 ||decode(max(         BUFFERED_DML_MISMATCH),'Y',        ' BUFFERED_DML_MISMATCH'       ||'( '||SUM(DECODE(BUFFERED_DML_MISMATCH,'Y',1,0))||')')

 ||decode(max(             PDML_ENV_MISMATCH),'Y',            ' PDML_ENV_MISMATCH'       ||'( '||SUM(DECODE(   PDML_ENV_MISMATCH,'Y',1,0))||')')

 ||decode(max(           INST_DRTLD_MISMATCH),'Y',          ' INST_DRTLD_MISMATCH'       ||'( '||SUM(DECODE( INST_DRTLD_MISMATCH,'Y',1,0))||')')

 ||decode(max(             SLAVE_QC_MISMATCH),'Y',            ' SLAVE_QC_MISMATCH'       ||'( '||SUM(DECODE(   SLAVE_QC_MISMATCH,'Y',1,0))||')')

 ||decode(max(            TYPECHECK_MISMATCH),'Y',           ' TYPECHECK_MISMATCH'       ||'( '||SUM(DECODE(  TYPECHECK_MISMATCH,'Y',1,0))||')')

 ||decode(max(           AUTH_CHECK_MISMATCH),'Y',          ' AUTH_CHECK_MISMATCH'       ||'( '||SUM(DECODE( AUTH_CHECK_MISMATCH,'Y',1,0))||')')

 ||decode(max(                 BIND_MISMATCH),'Y',                ' BIND_MISMATCH'       ||'( '||SUM(DECODE(       BIND_MISMATCH,'Y',1,0))||')')

 ||decode(max(             DESCRIBE_MISMATCH),'Y',            ' DESCRIBE_MISMATCH'       ||'( '||SUM(DECODE(   DESCRIBE_MISMATCH,'Y',1,0))||')')

 ||decode(max(             LANGUAGE_MISMATCH),'Y',            ' LANGUAGE_MISMATCH'       ||'( '||SUM(DECODE(   LANGUAGE_MISMATCH,'Y',1,0))||')')

 ||decode(max(          TRANSLATION_MISMATCH),'Y',         ' TRANSLATION_MISMATCH'       ||'( '||SUM(DECODE( TRANSLATION_MISMATCH,'Y',1,0))||')')

 --||decode(max(        ROW_LEVEL_SEC_MISMATCH),'Y',       ' ROW_LEVEL_SEC_MISMATCH'     ||'( '||SUM(DECODE( ROW_LEVEL_SEC_MISMATCH,'Y',1,0))||''

 ||decode(max(                  INSUFF_PRIVS),'Y',                 ' INSUFF_PRIVS'       ||'( '||SUM(DECODE(        INSUFF_PRIVS,'Y',1,0))||')')

 ||decode(max(              INSUFF_PRIVS_REM),'Y',             ' INSUFF_PRIVS_REM'       ||'( '||SUM(DECODE(    INSUFF_PRIVS_REM,'Y',1,0))||')')

 ||decode(max(         REMOTE_TRANS_MISMATCH),'Y',        ' REMOTE_TRANS_MISMATCH'       ||'( '||SUM(DECODE(REMOTE_TRANS_MISMATCH,'Y',1,0))||')')

 ||decode(max(     LOGMINER_SESSION_MISMATCH),'Y',    ' LOGMINER_SESSION_MISMATCH'       ||'( '||SUM(DECODE(LOGMINER_SESSION_MISMATCH,'Y',1,0))||')')

 ||decode(max(          INCOMP_LTRL_MISMATCH),'Y',         ' INCOMP_LTRL_MISMATCH'       ||'( '||SUM(DECODE( INCOMP_LTRL_MISMATCH,'Y',1,0))||')')

 ||decode(max(         OVERLAP_TIME_MISMATCH),'Y',        ' OVERLAP_TIME_MISMATCH'       ||'( '||SUM(DECODE(OVERLAP_TIME_MISMATCH,'Y',1,0))||')')

 --||decode(max(         SQL_REDIRECT_MISMATCH),'Y',        ' SQL_REDIRECT_MISMATCH'     ||'( '||SUM(DECODE( SQL_REDIRECT_MISMATCH,'Y',1,0))||''

 ||decode(max(         MV_QUERY_GEN_MISMATCH),'Y',        ' MV_QUERY_GEN_MISMATCH'       ||'( '||SUM(DECODE(MV_QUERY_GEN_MISMATCH,'Y',1,0))||')')

 ||decode(max(       USER_BIND_PEEK_MISMATCH),'Y',      ' USER_BIND_PEEK_MISMATCH'       ||'( '||SUM(DECODE(USER_BIND_PEEK_MISMATCH,'Y',1,0))||')')

 ||decode(max(           TYPCHK_DEP_MISMATCH),'Y',          ' TYPCHK_DEP_MISMATCH'       ||'( '||SUM(DECODE( TYPCHK_DEP_MISMATCH,'Y',1,0))||')')

 ||decode(max(           NO_TRIGGER_MISMATCH),'Y',          ' NO_TRIGGER_MISMATCH'       ||'( '||SUM(DECODE( NO_TRIGGER_MISMATCH,'Y',1,0))||')')

 ||decode(max(              FLASHBACK_CURSOR),'Y',             ' FLASHBACK_CURSOR'       ||'( '||SUM(DECODE(    FLASHBACK_CURSOR,'Y',1,0))||')')

 ||decode(max(        ANYDATA_TRANSFORMATION),'Y',       ' ANYDATA_TRANSFORMATION'       ||'( '||SUM(DECODE(ANYDATA_TRANSFORMATION,'Y',1,0))||')')

 --||decode(max(             INCOMPLETE_CURSOR),'Y',            ' INCOMPLETE_CURSOR'     ||'( '||SUM(DECODE(     INCOMPLETE_CURSOR,'Y',1,0))||''

 ||decode(max(          TOP_LEVEL_RPI_CURSOR),'Y',         ' TOP_LEVEL_RPI_CURSOR'       ||'( '||SUM(DECODE( TOP_LEVEL_RPI_CURSOR,'Y',1,0))||')')

 ||decode(max(         DIFFERENT_LONG_LENGTH),'Y',        ' DIFFERENT_LONG_LENGTH'       ||'( '||SUM(DECODE(DIFFERENT_LONG_LENGTH,'Y',1,0))||')')

 ||decode(max(         LOGICAL_STANDBY_APPLY),'Y',        ' LOGICAL_STANDBY_APPLY'       ||'( '||SUM(DECODE(LOGICAL_STANDBY_APPLY,'Y',1,0))||')')

 ||decode(max(                DIFF_CALL_DURN),'Y',               ' DIFF_CALL_DURN'       ||'( '||SUM(DECODE(      DIFF_CALL_DURN,'Y',1,0))||')')

 ||decode(max(                BIND_UACS_DIFF),'Y',               ' BIND_UACS_DIFF'       ||'( '||SUM(DECODE(      BIND_UACS_DIFF,'Y',1,0))||')')

 ||decode(max(        PLSQL_CMP_SWITCHS_DIFF),'Y',       ' PLSQL_CMP_SWITCHS_DIFF'       ||'( '||SUM(DECODE(PLSQL_CMP_SWITCHS_DIFF,'Y',1,0))||')')

 ||decode(max(         CURSOR_PARTS_MISMATCH),'Y',        ' CURSOR_PARTS_MISMATCH'       ||'( '||SUM(DECODE(CURSOR_PARTS_MISMATCH,'Y',1,0))||')')

 ||decode(max(           STB_OBJECT_MISMATCH),'Y',          ' STB_OBJECT_MISMATCH'       ||'( '||SUM(DECODE( STB_OBJECT_MISMATCH,'Y',1,0))||')')

 --||decode(max(             ROW_SHIP_MISMATCH),'Y',            ' ROW_SHIP_MISMATCH'     ||'( '||SUM(DECODE(     ROW_SHIP_MISMATCH,'Y',1,0))||''

 ||decode(max(             PQ_SLAVE_MISMATCH),'Y',            ' PQ_SLAVE_MISMATCH'       ||'( '||SUM(DECODE(   PQ_SLAVE_MISMATCH,'Y',1,0))||')')

 ||decode(max(        TOP_LEVEL_DDL_MISMATCH),'Y',       ' TOP_LEVEL_DDL_MISMATCH'       ||'( '||SUM(DECODE(TOP_LEVEL_DDL_MISMATCH,'Y',1,0))||')')

 ||decode(max(             MULTI_PX_MISMATCH),'Y',            ' MULTI_PX_MISMATCH'       ||'( '||SUM(DECODE(   MULTI_PX_MISMATCH,'Y',1,0))||')')

 ||decode(max(       BIND_PEEKED_PQ_MISMATCH),'Y',      ' BIND_PEEKED_PQ_MISMATCH'       ||'( '||SUM(DECODE(BIND_PEEKED_PQ_MISMATCH,'Y',1,0))||')')

 ||decode(max(           MV_REWRITE_MISMATCH),'Y',          ' MV_REWRITE_MISMATCH'       ||'( '||SUM(DECODE( MV_REWRITE_MISMATCH,'Y',1,0))||')')

 ||decode(max(         ROLL_INVALID_MISMATCH),'Y',        ' ROLL_INVALID_MISMATCH'       ||'( '||SUM(DECODE(ROLL_INVALID_MISMATCH,'Y',1,0))||')')

 ||decode(max(       OPTIMIZER_MODE_MISMATCH),'Y',      ' OPTIMIZER_MODE_MISMATCH'       ||'( '||SUM(DECODE(OPTIMIZER_MODE_MISMATCH,'Y',1,0))||')')

 ||decode(max(                   PX_MISMATCH),'Y',                  ' PX_MISMATCH'       ||'( '||SUM(DECODE(         PX_MISMATCH,'Y',1,0))||')')

 ||decode(max(          MV_STALEOBJ_MISMATCH),'Y',         ' MV_STALEOBJ_MISMATCH'       ||'( '||SUM(DECODE( MV_STALEOBJ_MISMATCH,'Y',1,0))||')')

 ||decode(max(      FLASHBACK_TABLE_MISMATCH),'Y',     ' FLASHBACK_TABLE_MISMATCH'       ||'( '||SUM(DECODE(FLASHBACK_TABLE_MISMATCH,'Y',1,0))||')')

 ||decode(max(          LITREP_COMP_MISMATCH),'Y',         ' LITREP_COMP_MISMATCH'       ||'( '||SUM(DECODE( LITREP_COMP_MISMATCH,'Y',1,0))||')')

 reason

from 

   gv$sql_shared_cursor 

  where sql_id = trim('&&sql_id')

group by 

   sql_id 




---------------------------------------

SELECT TRUNC (s.end_interval_time) sample_end,

MIN (q.snap_id) min_snapid,

MAX (q.snap_id) max_snapid,

q.sql_id,

q.plan_hash_value PHV,

SUM (q.EXECUTIONS_DELTA) exec,

SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

SUM (q.parse_calls_DELTA) HParse,

SUM (q.version_count) vers,

CEIL (

ROUND (

   SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

pio_exec,

CEIL (

ROUND (

   SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

lio_exec,

ROUND (

(SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

IO_Wait,

ROUND (

(SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

CPU_Wait,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_exec,

CEIL (

ROUND (

   SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

/ DECODE (

  TRUNC(ROUND (

(SUM (rows_processed_delta)

  / GREATEST (SUM (executions_delta), 1)),

1)),

  0, 1,

  ROUND (

(SUM (rows_processed_delta)

  / GREATEST (SUM (executions_delta), 1)),

1))

LIO_PER_ROW,

ROUND (

(ROUND (

(  SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

   (ROUND (

   (  SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

   1)

/ (1000 * 60)),

   4)

|| 'M'

exec_time,

(SELECT (SELECT reference

FROM xxcpf_pm_sql_statement_fix

   WHERE ROWNUM = 1

AND (hash_value = q.plan_hash_value

  OR hash_value =

(SELECT DBMS_UTILITY.

SQLID_TO_SQLHASH (q.sql_id)

   FROM DUAL)))

FROM DUAL)

defect_id

FROM dba_hist_sqlstat q, dba_hist_snapshot s

   WHERE     q.SQL_ID = TRIM ('875vxcp579422')

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time)

ORDER BY 1 DESC, q.sql_id, q.plan_hash_value;

------------- if table or view does not exist for above query 


SELECT TRUNC (s.end_interval_time) sample_end,

MIN (q.snap_id) min_snapid,

MAX (q.snap_id) max_snapid,

q.sql_id,

q.plan_hash_value PHV,

SUM (q.EXECUTIONS_DELTA) exec,

SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

SUM (q.parse_calls_DELTA) HParse,

SUM (q.version_count) vers,

CEIL (

ROUND (

   SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

pio_exec,

CEIL (

ROUND (

   SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

lio_exec,

ROUND (

(SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

IO_Wait,

ROUND (

(SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

CPU_Wait,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_exec,

CEIL (

ROUND (

   SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

   1))

/ DECODE (

  TRUNC(ROUND (

(SUM (rows_processed_delta)

  / GREATEST (SUM (executions_delta), 1)),

1)),

  0, 1,

  ROUND (

(SUM (rows_processed_delta)

  / GREATEST (SUM (executions_delta), 1)),

1))

LIO_PER_ROW,

ROUND (

(ROUND (

(  SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

   (ROUND (

   (  SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

   1)

/ (1000 * 60)),

   4)

|| 'M'

exec_time

FROM dba_hist_sqlstat q, dba_hist_snapshot s

   WHERE     q.SQL_ID = TRIM ('cx0spupaccgpd')

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time)

ORDER BY 1 DESC, q.sql_id, q.plan_hash_value;


--------------------------------------------------------------------------------------------------

Step:3: click F5(script execute) and pass plan hash value(2202985026)


SET LINESIZE 2000

SET PAGESIZE 5000

COL TABLE_NAME FORMAT A30

COL NUM_ROWS FORMAT A10

SET FEEDBACK OFF

COL PCT_ANALYZED FORMAT A15

COL LAST_ANALYZED FORMAT A20

COL USED_BLOCKS FORMAT A15

COL BLOCKS FORMAT A15

def plan_hash = &&plan_hash_value

set verify off


SELECT (lpad(' ',2*(depth-1)) ||' '||depth||' '||operation || ' ' || options || ' ' ||object_name||' '|| decode(access_predicates , null , null , 'access_predicates =' ||  access_predicates)

|| ' ' || decode( filter_predicates , null , null , 'filter_predicates = ' || filter_predicates ) || ' ' || 

PARTITION_START||'-'||PARTITION_STOP||' (Cost ='||COST||' '||'Card = '||Cardinality||' Bytes ='||bytes||')' ) Ex_Plan

FROM 

 SELECT DISTINCT operation , options , object_name , access_predicates , filter_predicates, COST , CARDINALITY , BYTES, ID , PARTITION_STOP , PARTITION_START,DEPTH FROM   xxcpf_pm_sql_plan

WHERE  

   plan_hash= &&plan_hash

 )

--and CHILD_NUMBER = 0

ORDER BY id;


SELECT   table_name, CEIL (num_rows) num_rows,

         ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows),

                2

               ) pct_analyzed,

         last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks,

         blocks,

         DECODE (num_rows,

                 0, 0,

                   ((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100

                   )

                 / blocks

                ) fragmentation,

      ( select stale_stats from dba_tab_statistics a where a.table_name = table_name and rownum=1)  as isstale

    FROM all_tables A

   WHERE (owner, table_name) IN (

            SELECT object_owner, object_name

              FROM  xxcpf_pm_sql_plan  a

             WHERE plan_hash= &&plan_hash

            UNION ALL

            SELECT table_owner, table_name

              FROM all_indexes

             WHERE (owner, index_name) IN (

                                           SELECT object_owner, object_name

                                             FROM xxcpf_pm_sql_plan a

                                            WHERE  plan_hash= &&plan_hash))

ORDER BY num_rows DESC

/


SET LINESIZE 2000

COL TABLE_NAME FORMAT A30

COL NUM_ROWS FORMAT A10

COL PCT_ANALYZED FORMAT A15

COL LAST_ANALYZED FORMAT A20

COL USED_BLOCKS FORMAT A15

COL BLOCKS FORMAT A15

SELECT   table_name, partition_name , CEIL (num_rows) num_rows,

         ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows),

                2

               ) pct_analyzed,

         last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks,

         blocks,

         DECODE (num_rows,

                 0, 0,

                   ((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100

                   )

                 / blocks

                ) fragmentation

    FROM  dba_tab_partitions

   WHERE (table_owner, table_name) IN (

            SELECT object_owner, object_name

              FROM xxcpf_pm_sql_plan a

             WHERE  plan_hash= &&plan_hash

            UNION ALL

            SELECT table_owner, table_name

              FROM all_indexes

             WHERE (owner, index_name) IN (

                                           SELECT object_owner, object_name

                                             FROM xxcpf_pm_sql_plan a

                                            WHERE  plan_hash= &&plan_hash))

ORDER BY num_rows DESC

/


set linesize 2000

set pagesize 50000

col table_name format a30

col index_name format a30

col column_name format a30

col COLUMN_POSITION format a15

col blevel format a6

col leaf_blocks format a6

col num_rows format a15

col pct_analyzed format a15

col last_analyzed format a20

col clustering_factor format a20

col uniqueness format a20

SELECT   i.table_name, i.status, i.index_name, c.column_name,

         c.column_position, i.blevel, i.leaf_blocks,

         CEIL (i.num_rows) num_rows,

         DECODE (i.num_rows,

                 0, 0,

                 ROUND (i.sample_size * 100 / i.num_rows, 2)

                ) pct_analyzed,

         i.last_analyzed, i.clustering_factor, i.uniqueness

    FROM all_indexes i, all_ind_columns c

   WHERE (i.owner, i.index_name) IN (

                                           SELECT object_owner, object_name

                                             FROM xxcpf_pm_sql_plan a

                                            WHERE  plan_hash= &&plan_hash)

     AND i.index_name = c.index_name

     AND i.table_owner = c.table_owner

     AND i.table_name = c.table_name

ORDER BY 1, 3, 5

/   

set pagesize 5000

set linesize 2000

col table_name format a30

col column_name format a30

col num_nulls format a10

col num_distinct format a10

col density format a10

SELECT table_name, column_name, num_nulls, num_distinct, density, histogram

  FROM all_tab_cols

 WHERE (owner, table_name) IN (

          SELECT object_owner, object_name

            FROM xxcpf_pm_sql_plan a

           WHERE  plan_hash= &&plan_hash

          UNION ALL

          SELECT table_owner, table_name

            FROM all_indexes

           WHERE (owner, index_name) IN (

                                           SELECT object_owner, object_name

                                             FROM xxcpf_pm_sql_plan a

                                            WHERE  plan_hash= &&plan_hash))

     AND EXISTS (

            SELECT *

              FROM xxcpf_pm_sql_plan a

             WHERE  plan_hash= &&plan_hash

               AND INSTR (access_predicates || '   ' || filter_predicates,

                          column_name

                         ) > 0)

ORDER BY 1, 2


/


==============AWR


SELECT

output

FROM

TABLE

(dbms_workload_repository.awr_report_html

(1132959846,2,28820,28821)

); 


---(DBID inst ID begin end snap)


SELECT output FROM TABLE(

   DBMS_WORKLOAD_REPOSITORY.ASH_REPORT_TEXT(

     1557521192,  1, 5390, 5392) ) ;

----------or  (DBID inst ID begin end snap)



SELECT /*+parallel(8)*/ sql_id,

COUNT(*),

event

FROM gv$active_session_history

WHERE sample_time BETWEEN TO_DATE('16-mar-2022 22:40:29', 'DD-Mon-YYYY HH24:MI:SS') AND TO_DATE('16-mar-2022 22:53:05', 'DD-Mon-YYYY HH24:MI:SS')

AND upper(module) LIKE '%WINNERS_BATCH%'

AND sql_id = '4cb3ufq8126jb'

GROUP BY sql_id,

event

ORDER BY COUNT(1) DESC;


Step:3: pass pHv (206559214)


select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ALL'));


select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ADVANCED'));



===

select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE'))



select * from table(dbms_xplan.display_awr ('dwh6crb9kv06n', format => 'ADVANCED +REMOTE +PEEKED_BINDS +outline +iostats +ALLSTATS LAST'))



select * from table(dbms_xplan.display_awr('76bk7bjxkxu0y',format =>'outline'))


************ To check Histogram Stats on Table :


SELECT COLUMN_NAME, NOTES, HISTOGRAM

FROM USER_TAB_COL_STATISTICS

WHERE TABLE_NAME = 'XXCP_VT_INTERFACE';


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

SQL> SELECT * FROM TABLE(DBMS_XPLAN.display_cursor(sql_id=>'9ux2cxrxq8dp3', format=>'ALLSTATS LAST +cost +bytes'));


SELECT*

FROM dba_hist_sql_plan

WHERE sql_id='81f9vxmvjudw8'


SELECT*

FROM xxcpf_pm_sql_plan

WHERE sql_id='81f9vxmvjudw8'


SELECT*

FROM gv$sql_plan

WHERE sql_id='81f9vxmvjudw8'


dbms_xplan.display_awr/ DBMS_XPLAN.display_cursor

gv$sql_plan

dba_hist_sql_plan

xxcpf_pm_sql_plan

GV$SQL_PLAN

select * from GV$SQL_PLAN_MONITOR WHERE SQL_ID='d00zztwfbq25f'

------------------------------------

************* if query is Running :


SELECT inst_id,sql_id,

plan_hash_value,

disk_reads,

buffer_gets,

rows_processed,

executions,

(elapsed_time / 1000 / 1000) elapsed_time,sql_profile

FROM gv$sql

WHERE sql_id IN

('0z4kcp38wypn5')


To raise a case :


Please reach out to DBA through Click to Spark. Below is the url and select Impacted service offering : oracle database

Available DBA will assist you further.

https://clicktospark.cloudapps.cisco.com/home

For Creating a Case with DBA Team.

https://cisco.service-now.com

Select Impacted service offering as : Oracle database


***************** select owner,table_name,num_rows,last_analyzed,stale_stats from DBA_TAB_STATISTICS where table_name='DLP_SYSTEM_ITEMS'

Table Stats :

------------


SELECT table_name, CEIL (num_rows) num_rows,

ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows),

2

) pct_analyzed,

last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks,

blocks,

DECODE (num_rows,

0, 0,

((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100

)

/ blocks

) fragmentation,

( SELECT STALE_STATS FROM DBA_TAB_STATISTICS D WHERE D.TABLE_NAME= A.TABLE_NAME AND A.OWNER = D.OWNER and object_type = 'TABLE') STALE

FROM all_tables A

WHERE (owner, table_name) IN (

SELECT object_owner, object_name

FROM xxcpf_pm_sql_plan a

WHERE plan_hash= &&plan_hash_value

UNION ALL

SELECT table_owner, table_name

FROM all_indexes

WHERE (owner, index_name) IN (

SELECT object_owner, object_name

FROM xxcpf_pm_sql_plan a

WHERE plan_hash= &&plan_hash_value))

ORDER BY num_rows DESC


To check stale stats  using SQL ID :

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

select distinct owner, table_name, STALE_STATS, last_analyzed, stattype_locked

  from dba_tab_statistics

  where (owner, table_name) in

  (select distinct owner, table_name

          from dba_tables

          where ( table_name)

          in ( select object_name

                  from gv$sql_plan

                  where upper(sql_id) = upper('&sql_id') and object_name is not null))

  --and STALE_STATS='YES'


Script for index stats :

------------------------

select * from dba_ind_statistics where table_name='' and stale_stats='YES';(No stats showing) 



To find schema using sql id :

-----------------------------


select * from gv$session where sid='1139' -----> schema name SYS



Top CPU Consuming Session in last 10 min :

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


select * from

(

select session_id, session_serial#, count(*)

from v$active_session_history

where session_state= 'ON CPU' and

sample_time >= sysdate - interval '10' minute

group by session_id, session_serial#

order by count(*) desc

);



To know details from gv$sql :

----------------------------


SELECT*

FROM gv$sql

WHERE sql_id='5uhjrjypmzrgv'


TO check Bind peeking :(https://learningoracledba.wordpress.com/2018/02/23/child-cursor-bind-peeking-roll_invalid_mismatch/)

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


The Sql text has many bind variables, Sometimes Oracles goes for adaptive cursor sharing to peek the bind variables and avoids bad plans.


How can we check if we have any bind peeking in our case


We can see the Bind aware is No , So we don’t have any bind peeking happening here



SELECT sql_id, child_number, is_bind_sensitive, is_bind_aware

FROM   gv$sql

WHERE  SQL_ID='7crqdmwxugnrb';


SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE IS_BIND_AWARE

7crqdmwxugnrb 0 Y N

7crqdmwxugnrb 0 Y N

7crqdmwxugnrb 1 Y N

7crqdmwxugnrb 2 Y N

7crqdmwxugnrb 0 Y N

7crqdmwxugnrb 0 Y N


Query to check SQL profile picking or not :

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


SELECT inst_id,

sql_id,

EXECUTIONS,

PLAN_HASH_VALUE,

CEIL (ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1))

pio_exec,

CEIL (ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1))

lio_exec,

ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)

Rows_exec,

ROUND (

( ROUND (

( SUM (ELAPSED_TIME)

/ GREATEST (SUM (EXECUTIONS), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

( ROUND (

( SUM (ELAPSED_TIME)

/ GREATEST (SUM (EXECUTIONS), 1)

/ 1000),

1)

/ (1000 * 60)),

4)

|| 'M'

exec_time,

SQL_profile

FROM gv$sqlarea

WHERE sql_id = 'art0f01ftyq9b' --and inst_id=3

GROUP BY inst_id,

sql_id,

EXECUTIONS,

PLAN_HASH_VALUE,SQL_profile;



QUERY S TO KNOW FROM WHICH PACKAGE IT IS CALLING :

--------------------------------------------------


select * from xxcpf_pm_snapshot where sql_id='5xdtmvsyzcncf'

order by snap_date_time desc  

-----1039552910 ----SQL_HASh_VALUE



SELECT*

FROM xxcpf_pm_sqlarea

WHERE sql_hash =1039552910

ORDER BY TRUNC (snap_date_time) DESC

------2191580 PROG ID  



select * from dba_objects

where object_id =2191580(PROG_ID)

-----XXDH_ATS_OUTBOUND_PKG ----> obj

----PACKAGE BODY ------> obj type


WFPUBLISH XXDH_ATS_OUTBOUND_PKG 2191580 PACKAGE BODY 1/16/2017 6:30:10 AM 7/29/2019 7:44:10 AM 2019-07-29:07:44:10 VALID N N N 2 NONE Y N


-----XXDH_ATS_OUTBOUND_PKG ---> f4 ----> tOggle

WFPUBLISH."XXDH_ATS_OUTBOUND_PKG" ------> pkg body call

WFPUBLISH ------> owner /schema




   

-----For Distinct Values----

select /*+parallel(32)*/RUN_STATUS,count(*)

from WFPUBLISH.XXDH_OUTBOUND_REQUESTS

group by RUN_STATUS

order by 2 desc

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


select /*+parallel(8)*/ count(*), SOURCE,ORDER_TYPE,PROCESS_FLAG 

from XXCTS_O.XXCTS_PLAN_ORDER_STAGING 

group by SOURCE,ORDER_TYPE,PROCESS_FLAG

order by 2 desc


Select INST_ID,name,datatype_string,value_string from gv$sql_bind_capture where sql_id = 'frv6z0mjuckw9';


SQL> select index_name,index_type,owner,status from dba_indexes where table_name='XXGCO_RPT_GENERIC_NEW_TEMP';


INDEX_NAME INDEX_TYPE OWNER STATUS


XXGCO_RPT_GENERIC_NEW_TEMP_N1 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N2 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N3 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N4 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N5 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N6 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N7 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N8 NORMAL XXGCO UNUSABLE

XXGCO_RPT_GENERIC_NEW_TEMP_N9 NORMAL XXGCO UNUSABLE


9 rows selected.


   

----bind variables--------

select name,datatype_string,value_string,count(*)

from dba_hist_Sqlbind

where sql_id ='&sql_id'

group by name,datatype_string,value_string

order by 4 desc;


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


select * from dba_db_links where db_link like '%XXCTS_XELUS_CTS%'

remote DB is VISPROD


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

select name , value_string, datatype_string ,last_captured,was_captured , count(*) from dba_hist_sqlbind where sql_id = '7aqj16gxkauc0'

group by name , value_string, datatype_string ,last_captured,was_captured order by 4 desc;


SELECT TO_CHAR (last_captured, 'dd-Mon-yy hh24:mi:ss AM') last_captured,

       name bind,

       value_string VALUE_STR,

       datatype_string data_type

  FROM gv$sql_bind_capture

 WHERE sql_id = '&sql_id' AND was_captured = 'YES'


gv$bincapture


-----5xdtmvsyzcncf

----> showing nothing(No bind variables present in sql_text)


************* VVIMP Query :::::: 


select h.* from dba_hist_active_sess_history h

where

1=1

--and session_id=5571

--and h.session_serial#=64445

and h.sample_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS')

and h.instance_number=9

--and h.session_state='ON CPU'

and h.sql_id='bmngs1g8p1wu8'

order by sample_time ;



select

s.*

from dba_hist_Sqlstat s,dba_hist_snapshot n where

s.instance_number=9

and 1=1

and s.snap_id=n.snap_id and s.instance_number=n.instance_number

--and s.executions_delta>0

--and s.instance_number in(5,8)

and s.sql_id='bmngs1g8p1wu8'

--and round((sum(s.physical_read_bytes_delta)/1024/1024)/sum(s.executions_delta),2)>100

and n.begin_interval_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS')

order by s.snap_id;select h.* from dba_hist_active_sess_history h

where

1=1

--and session_id=5571

--and h.session_serial#=64445

and h.sample_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS')

and h.instance_number=9

--and h.session_state='ON CPU'

and h.sql_id='bmngs1g8p1wu8'

order by sample_time ;



select

s.*

from dba_hist_Sqlstat s,dba_hist_snapshot n where

s.instance_number=9

and 1=1

and s.snap_id=n.snap_id and s.instance_number=n.instance_number

--and s.executions_delta>0

--and s.instance_number in(5,8)

and s.sql_id='bmngs1g8p1wu8'

--and round((sum(s.physical_read_bytes_delta)/1024/1024)/sum(s.executions_delta),2)>100

and n.begin_interval_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS')

order by s.snap_id;


=================================Statement FIX


INSERT INTO xxcpf_pm_sql_statement_fix (hash_value,

REFERENCE,

sql_id,

creation_date,

update_date,

hash_type,

gbp,

paged,

case_type,

module)

VALUES (2749603398,

'PRB0062786',

'gu9fhks50cwm8',

SYSDATE,

SYSDATE,

'Plan_Hash',

NULL,

'N',

'P',

NULL);


commit


*******


SQLs from dba_hist_active_sess_history :-


SELECT /*+ parallel */

        q.sql_id,

         SUM (q.EXECUTIONS_DELTA)             exec,

         SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

            ROUND (

               (  ROUND (

                     (  SUM (ELAPSED_TIME_delta)

                      / GREATEST (SUM (executions_delta), 1)

                      / 1000),

                     1)

                / 1000),

               4)

         || 'S/'

         || ROUND (

               (  ROUND (

                     (  SUM (ELAPSED_TIME_delta)

                      / GREATEST (SUM (executions_delta), 1)

                      / 1000),

                     1)

                / (1000 * 60)),

               4)

         || 'M'

            exec_time

    FROM dba_hist_sqlstat q, dba_hist_snapshot s

   WHERE     parsing_schema_name LIKE '%QBLRO%'

         AND q.SQL_ID IN (SELECT DISTINCT sql_id

                            FROM dba_hist_active_sess_history

                           WHERE module LIKE '%JDBC%')

         AND s.snap_id = q.snap_id

         AND s.dbid = q.dbid

         AND s.instance_number = q.instance_number

GROUP BY q.sql_id




SQLs from xxcpf_pm_sqlarea :-




SELECT sql_id,

         MAX (executions)                            execs,

         ROUND (MAX (load_duration) * 24 * 60 * 60, 2) total_sec,

            ROUND (

               (  (MAX (load_duration) / GREATEST (MAX (executions), 1))

                * 24

                * 60

                * 60),

               2)

         || 'sec/'

         || ROUND (

               ( (MAX (load_duration) / GREATEST (MAX (executions), 1)) * 24 * 60),

               2)

         || 'min'

            Time_per_Exec

    FROM xxcpf_pm_sqlarea

   WHERE sql_id IN (SELECT DISTINCT sql_id

                      FROM xxcpf_pm_snapshot

                     WHERE module LIKE '%JDBC%' AND schema LIKE '%QBLRO%')

GROUP BY sql_id;


*************


SELECT snap_date_time,

sql_id,

plan_hash,

executions,

ROUND (load_duration * 24 * 60 * 60, 2) total_secs,

CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1))

pio_per_exec,

CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

lio_per_exec,

ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1)

Rows_per_exec,

ROUND (

CEIL (

ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1))

/ GREATEST (

ROUND (

(SUM (rows_processed) / GREATEST (SUM (executions), 1)),

1),

1),

2)

LIO_PER_ROW,

ROUND (

( (load_duration / GREATEST (SUM (executions), 1))

* 24

* 60

* 60),

2)

|| 'sec/'

|| ROUND (

( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60),

2)

|| 'min'

Time_per_Exec

FROM xxcpf_pm_sqlarea

WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash)

GROUP BY sql_id,

plan_hash,

executions,

buffer_gets,

disk_reads,

executions,

snap_date_time,

load_duration

ORDER BY snap_date_time DESC;


*******


INSERT INTO xxcpf_pm_sql_statement_fix (REFERENCE,

HASHTYPE,

HASHVALUE,

CREATED_BY,

SQL_ID,

FIRST_ASSIGNED_DATE,

GBP,

RELEASE_TD,

PAGED,

CASE_TYPE,

MODULE,

ANALYST_NAME,

DB_NAME,

ENVIRONMENT_TYPE,

REQUEST_TYPE,

CASE_PRIORITY,

PROBLEM_TYPE,

CASE_STATUS,

CASE_RECOMMENDATION,

QUARTER_DETAIL,

CASE_REQUESTOR,

CASE_REQUESTOR_MANAGER,

WEEK_NUMBER,

CONC_PROG_ID)

VALUES ('INC7408576',

'Plan Hash',

313127912,

'aditytha',

'f4rgw5jmbr745',

SYSDATE,

NULL,

NULL,

NULL,

'Reactive',

'JDBC Thin Client',

'Aditya Thakur',

'OTMPRD',

'PRODUCTION',

'INC',

'P5',

'Code Design-Query Rewrite',

'Analysis Updated',

'Query Re-write',

'Q4FY22',

'macanton',

'mzakki',

1,

NULL);



************* Stesp to enable 10053/10046 Trace :


alter session set tracefile_identifier='case3fixcontrols'; 


alter session set timed_statistics = true; 


alter session set statistics_level= 'all'; 


alter session set max_dump_file_size = unlimited; 


alter session set "_fix_control"='13831671:0';

alter session set "_fix_control"='12555499:0'; 

alter session set "_fix_control"='26527656:0';


alter session set events '10053 trace name context forever, level 12'; 


SELECT  XPSA.PART_NUMBER        PART_NUMBER,

       XPSA.LOCATION           LOCATION,

       XPSA.LAST_UPDATE_DATE   STK_LAST_UPDATE_DATE,

       XPSA.CREATION_DATE      STK_CREATION_DATE,

       XPSA.REPAIR_WIP_QTY     REPAIR_WIP_QTY,

       XPSA.ACT_OHB_QTY        ACT_OHB_QTY,

       XPSA.REPAIR_BAD_QTY     REPAIR_BAD_QTY,

       XPSA.RETURN_BAD_QTY     RETURN_BAD_QTY,

       XPSA.RPRXDOC_QTY        RPRXDOC_QTY,

       XPSA.REPAIR_STOCK_QTY   REPAIR_STOCK_QTY,

       XPSA.RPRNNET_QTY        RPRNNET_QTY,

       XPSA.REPAIR_FGI_QTY     REPAIR_FGI_QTY,

       XPSA.REPAIR_WIP2_QTY    REPAIR_WIP2_QTY,

       XPSA.REPAIR_INTR_QTY    REPAIR_INTR_QTY,

       XPSA.AMOUNTCUSTOM7      AMOUNTCUSTOM7,

       XPSA.AMOUNTCUSTOM8      AMOUNTCUSTOM8,

       XPSA.AMOUNTCUSTOM9      AMOUNTCUSTOM9,

       RPR_O_QTY.OPEN_QUANTITY REPAIR_OPEN_QTY,

       NULL                    LOC_PRIORITY,

       SYSDATE                 CREATION_DATE,

       :B2                     CREATED_BY,

       SYSDATE                 LAST_UPDATE_DATE,

       :B2                     LAST_UPDATED_BY,

       :B1                     LAST_UPDATE_LOGIN,

       NULL                    REPAIR_WASHRATE,

       NULL                    PREV_PRIORITY_LOC

  FROM C2S_STOCK_AMOUNT_V_test XPSA,

       (  SELECT XPOD.SHIP_FROM_ORG_CODE,

                 XPOD.ORDERED_PART,

                 SUM (

                    (CASE

                        WHEN XPOD.OE_LINE_ID IS NOT NULL

                        THEN

                           (  NVL (XPOD.ORDERED_QUANTITY, 0)

                            - NVL (XPOD.SHIPPED_QUANTITY, 0))

                        ELSE

                           (  NVL (XPOD.REPAIR_QUANTITY, 0)

                            - NVL (XPOD.REPAIR_CANCELLED_QUANTITY, 0))

                     END))

                    OPEN_QUANTITY

            FROM APPS.XXCTS_PLAN_PDL_ORDER_DATA XPOD

           WHERE XPOD.ORDER_TYPE = 'INTERNAL-REPAIR'

        GROUP BY XPOD.SHIP_FROM_ORG_CODE, XPOD.ORDERED_PART) RPR_O_QTY

 WHERE     1 = 1

       AND XPSA.LOCATION = RPR_O_QTY.SHIP_FROM_ORG_CODE(+)

       AND XPSA.PART_NUMBER = RPR_O_QTY.ORDERED_PART(+);


alter session set events '10053 trace name context off';


*************


/* Formatted on 03/12/2021 11:35:12 (QP5 v5.294) */

DECLARE

   l_ph             NUMBER := 159833193;

   l_ref            VARCHAR2 (50) := 'PRB0077471';

   l_sql_id         VARCHAR2 (50) := 'g7fhts92rapsj';

   l_module         VARCHAR2 (100) := 'SQL*Plus';

   l_conc_prog_id   NUMBER := NULL;

   l_qe             VARCHAR2 (50) := NULL;

   l_rel            VARCHAR2 (50) := NULL;

BEGIN

   BEGIN

      INSERT INTO xxcpf_pm_sql_statement_fix (hash_value,

                                              REFERENCE,

                                              sql_id,

                                              creation_date,

                                              update_date,

                                              hash_type,

                                              gbp,

                                              paged,

                                              case_type,

                                              module,

                                              CONCURRENT_PROGRAM_ID)

           VALUES (DBMS_UTILITY.SQLID_TO_SQLHASH (l_sql_id),

                   l_ref,

                   l_sql_id,

                   SYSDATE,

                   SYSDATE,

                   'SQL_Hash',

                   NULL,

                   'N',

                   'P',

                   l_module,

                   l_conc_prog_id);

   EXCEPTION

      WHEN OTHERS

      THEN

         DBMS_OUTPUT.put_line ('SQL Hash already exists');

   END;


   BEGIN

      IF l_ph != 0

      THEN

         INSERT INTO xxcpf_pm_sql_statement_fix (hash_value,

                                                 REFERENCE,

                                                 sql_id,

                                                 creation_date,

                                                 update_date,

                                                 hash_type,

                                                 gbp,

                                                 paged,

                                                 case_type,

                                                 module,

                                                 CONCURRENT_PROGRAM_ID)

              VALUES (l_ph,

                      l_ref,

                      l_sql_id,

                      SYSDATE,

                      SYSDATE,

                      'Plan_Hash',

                      NULL,

                      'N',

                      'P',

                      l_module,

                      l_conc_prog_id);

      END IF;

   EXCEPTION

      WHEN OTHERS

      THEN

         DBMS_OUTPUT.put_line ('Plan Hash already exists');

   END;


   IF SQL%FOUND

   THEN

      DBMS_OUTPUT.put_line ('Something was inserted');

      COMMIT;

   END IF;

END;


/*


QE Issues


DECLARE

   l_ph             NUMBER := 3879424810;

   l_ref            VARCHAR2 (50) := 'PRB00602214';

   l_sql_id         VARCHAR2 (50) := '433us6nv8j3fq';

   l_module         VARCHAR2 (100) := 'JDBC Thin Client';

   l_conc_prog_id   NUMBER := null;

   l_qe             VARCHAR2 (50) := 'Q2FY21';

   l_rel            VARCHAR2 (50) := null;

BEGIN

   BEGIN

      INSERT INTO xxcpf_pm_sql_statement_fix (hash_value,

                                              REFERENCE,

                                              sql_id,

                                              creation_date,

                                              update_date,

                                              hash_type,

                                              gbp,

                                              paged,

                                              case_type,

                                              module,

                                              CONCURRENT_PROGRAM_ID,

                                              QE_RELATED,

                                              RELEASE_TD)

           VALUES (DBMS_UTILITY.SQLID_TO_SQLHASH (l_sql_id),

                   l_ref,

                   l_sql_id,

                   SYSDATE,

                   SYSDATE,

                   'SQL_Hash',

                   NULL,

                   'N',

                   'P',

                   l_module,

                   l_conc_prog_id,

                   l_qe,

                   l_rel);

   EXCEPTION

      WHEN OTHERS

      THEN

         DBMS_OUTPUT.put_line ('SQL Hash already exists');

   END;


   BEGIN

      IF l_ph != 0

      THEN

         INSERT INTO xxcpf_pm_sql_statement_fix (hash_value,

                                                 REFERENCE,

                                                 sql_id,

                                                 creation_date,

                                                 update_date,

                                                 hash_type,

                                                 gbp,

                                                 paged,

                                                 case_type,

                                                 module,

                                                 CONCURRENT_PROGRAM_ID,

                                                 QE_RELATED,

                                                 RELEASE_TD)

              VALUES (l_ph,

                      l_ref,

                      l_sql_id,

                      SYSDATE,

                      SYSDATE,

                      'Plan_Hash',

                      NULL,

                      'N',

                      'P',

                      l_module,

                      l_conc_prog_id,

                      l_qe,

                      l_rel);

      END IF;

   EXCEPTION

      WHEN OTHERS

      THEN

         DBMS_OUTPUT.put_line ('Plan Hash already exists');

   END;


   IF SQL%FOUND

   THEN

      DBMS_OUTPUT.put_line ('Something was inserted');

      COMMIT;

   END IF;

END;


*/






************


this is the query for inserting the details in statement fix table



To check statement fix entry :


select * from xxcpf_pm_sql_statement_fix where REFERENCE='PRB0065646'


select * from xxcpf_pm_sql_statement_fix where sql_id='d19qvv2n7dwwc'



select * from gv$sqlarea where sql_id='dxm217x42hhfc'



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


---------------Parsing schema

SELECT TRUNC (s.end_interval_time) sample_end,

MIN (q.snap_id) min_snapid,

MAX (q.snap_id) max_snapid,

q.sql_id,

q.plan_hash_value PHV,

SUM (q.EXECUTIONS_DELTA) exec,

SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total,

SUM (q.parse_calls_DELTA) HParse,

SUM (q.version_count) vers,

CEIL (

ROUND (

SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1),

1))

pio_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

lio_exec,

ROUND (

(SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

IO_Wait,

ROUND (

(SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000),

1)

/ 1000

CPU_Wait,

ROUND (

(SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)),

1)

Rows_exec,

CEIL (

ROUND (

SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1),

1))

/ DECODE (

TRUNC(ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1)),

0, 1,

ROUND (

(SUM (rows_processed_delta)

/ GREATEST (SUM (executions_delta), 1)),

1))

LIO_PER_ROW,

ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ 1000),

4)

|| 'S/'

|| ROUND (

(ROUND (

( SUM (ELAPSED_TIME_delta)

/ GREATEST (SUM (executions_delta), 1)

/ 1000),

1)

/ (1000 * 60)),

4)

|| 'M'

exec_time,

(SELECT (SELECT reference

FROM xxcpf_pm_sql_statement_fix

WHERE ROWNUM = 1

AND (hash_value = q.plan_hash_value

OR hash_value =

(SELECT DBMS_UTILITY.

SQLID_TO_SQLHASH (q.sql_id)

FROM DUAL)))

FROM DUAL)

defect_id,

parsing_schema_name

FROM dba_hist_sqlstat q, dba_hist_snapshot s

WHERE q.SQL_ID = TRIM ('&sql_id')

AND s.snap_id = q.snap_id

AND s.dbid = q.dbid

AND s.instance_number = q.instance_number

GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time),parsing_schema_name

ORDER BY 1 DESC, q.sql_id, q.plan_hash_value;


Observations :


1. we could see Plan fluctuation for the SQL

2. SQL is going with sub Optimal Plan

3. We could see the Top wait event is  db file sequential read

4. SQL is getting called from the package XXCTS_RPR_ECO_INVOICE_CRT_PKG (PACKAGE BODY call)( PROG ID 142545034 Prog Line #1146)

5. showing index stats as stale and PCT Analyzed is not 100% analyzed.

6. We could see increase in number of executions and Load


Kindly check if any additional joining condition/filter could be added to the query. If not, then the query is already optimal.


RECOMMENDATION:


1. Please gather the stats on the tables and indexes with 100% with no_invalidate=> false option .


2. AS Part of LTF/Fix Please use below modified query 


SELECT /*+  leading(MSB) use_nl (MSB MMT)  */

   COUNT (MMT.TRANSACTION_ID) REC_COUNT

  FROM MTL_MATERIAL_TRANSACTIONS MMT,

   MTL_UNIT_TRANSACTIONS MUT,

   MTL_SYSTEM_ITEMS_B MSB

WHERE     MMT.TRANSACTION_ID = MUT.TRANSACTION_ID

   AND MMT.INVENTORY_ITEM_ID = MUT.INVENTORY_ITEM_ID

   AND MMT.ORGANIZATION_ID = MUT.ORGANIZATION_ID

   AND MSB.INVENTORY_ITEM_ID = MMT.INVENTORY_ITEM_ID

   AND MSB.ORGANIZATION_ID = XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID ()

   AND MMT.SHIPMENT_NUMBER IS NOT NULL

   AND MSB.SEGMENT1 = UPPER ( :B4)

   AND UPPER (MUT.SERIAL_NUMBER) = UPPER ( :B3)

   AND MMT.ORGANIZATION_ID = :B2

   AND MMT.TRANSACTION_DATE >= :B1

   AND (   MSB.ENABLED_FLAG = 'Y'

OR SYSDATE BETWEEN MSB.START_DATE_ACTIVE AND MSB.END_DATE_ACTIVE)


3. Please test/implement it in lower environment First and then in Prod also provide us Pre and Post level 12  Tkprof to validate the performance gain for the same


RECOMMENDATION: 


1. The optimizer requires up-to-date statistics for the table in order to select a good execution plan 

  Please gather the stats on tables with PCT Analyzed 100% and no_invalidate=> false option .Make sure No stale stats.


2. Make sure gather stats need to running before Running the job because if you Run it when the job is Running it may impact the Performance



3.As part of STF, providing SQL profile script (attached in case).


Before deploying the profile, please follow below steps:


a. Cancel the current run of the program.

b. DBAs should flush the SQL_ID(byv8at426gqxx) from the shared pool from all the nodes.

c. Deploy the profile script.

d. Run the program.



select * from gv$sql where sql_id ='21anmb829xsyh' ==== Rows Proccessed


Observations :

--------------

1. Plan fluctuation

2. Logical I/O s high 

3. showing table and index stats are stale and not 100% analysed.


Suggestions :

1. Please gather the stats on the tables with 100% with no_invalidate=> false option .


2. Make sure no stale stats on tables and indexes


RECOMMENDATION: 


1. The optimizer requires up-to-date statistics for the table in order to select a good execution plan 

  Please gather the stats on tables with PCT Analyzed 100% and no_invalidate=> false option .

Make sure No stale stats.


2. Make sure gather stats need to running before Running the job because if you Run it when the job is Running it may impact the Performance



3.As part of STF, providing SQL profile script (attached in case).


Before deploying the profile, please follow below steps:


a. Cancel the current run of the program.

b. DBAs should flush the SQL_ID(byv8at426gqxx) from the shared pool from all the nodes.

c. Deploy the profile script.

d. Run the program.


*************************************************************************


SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME,

SQL_ID,

PLAN_HASH_VALUE,

SUM (EXECUTIONS) EXECUTIONS,

sum(fetches) fetches,

ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC,

ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1)

PIO_PER_EXEC,

ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1)

LIO_PER_EXEC,

ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)

ROWS_PER_EXEC,

ROUND (

(SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1))

/ GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1),

1),

1)

lio_per_row,

ROUND (

(SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1),

1)

|| 'ms/'

|| ROUND (

(SUM (ELAPSED_TIME) / 1000 / 1000)

/ GREATEST (SUM (EXECUTIONS), 1),

2)

|| 'sec/'

|| ROUND (

(SUM (ELAPSED_TIME) / 1000 / 1000 / 60)

/ GREATEST (SUM (EXECUTIONS), 1),

1)

|| 'min'

TIME_PER_EXEC, --max(sql_profile) sqlprofile,

round( ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)/sum(fetches),2) rows_per_fetch

FROM GV$SQL

WHERE SQL_ID IN ('b7wtvhymg6spy', '82px5przh5h27')

GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME)

ORDER BY 1 DESC;
















---------------------How to run tkprof in sql * plus :


Step : 1 


ALTER SESSION SET TRACEFILE_IDENTIFIER = 'May21';


alter session set max_dump_file_size = unlimited;


ALTER SESSION SET TIMED_STATISTICS=TRUE;


ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';


SET ARRAYSIZE 5000;


SET AUTOTRACE TRACEONLY;


var B1 varchar2(32)

exec :B1 := '22822281';


var B2 number;

exec :B2 := 810270178;


SELECT MAX (TRANSACTION_ID), SYSDATE

FROM SCD.IF_PRODUCT_MASTER

WHERE TRANSACTION_ID > :B2

AND GET_DUNS (PARTNER_ID, PARTNER_ID, '$NA$') = :B1;


SET autotrace off;



step : 2 : click space in Toad


Editor----> run as sql -----> wait and press Enter  ----> ed bind.sql


Create a text file "bind" and paste below content and 


close file and run @bind.sql


Query to find min and max snap :

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


SELECT MIN (snap_id), MAX (snap_id)

FROM dba_hist_snapshot

WHERE begin_interval_time BETWEEN TO_DATE ('10/06/2021 00:20:33',

'MM/DD/YYYY HH24:MI:SS')

AND TO_DATE ('10/10/2021 01:19:32',

'MM/DD/YYYY HH24:MI:SS');


To find Cpu usage for concurrent program and sql id :

------------------------------------------------------


  SELECT parsing_schema_name,sql_id,osuser,module,

         SUM (total_elapsed_secs) "Elapsed secs",

         SUM (total_cpu_secs) "CPU secs",

         SUM (percent_overall_cpu_used) "% CPU used",

         SUM (total_dbtime_secs) "DBTIME secs",

         SUM (percent_overall_dbtime_used) "% DBTIME used",

         SUM (total_buf_gets) "Buffer Gets",

         SUM (percent_overall_buf_gets_used) "% Buffer Gets",

         SUM (total_disk_reads) "Disk Reads",

         SUM (pct_overall_disk_reads_used) "% Disk Reads"

    FROM (SELECT mod_sql_list.*,

                 SUM (total_cpu_secs) OVER (PARTITION BY NULL)

                    overall_cpu_time_used,

                 SUM (total_dbtime_secs) OVER (PARTITION BY NULL)

                    overall_dbtime_used,

                 --  SUM (total_elapsed_secs) OVER (PARTITION BY NULL)   overall_elapsed_time_used,

                 ROUND (

                      total_cpu_secs

                    / SUM (total_cpu_secs) OVER (PARTITION BY NULL)

                    * 100,

                    3)

                    Percent_overall_CPU_used,

                 ROUND (

                      total_dbtime_secs

                    / SUM (total_dbtime_secs) OVER (PARTITION BY NULL)

                    * 100,

                    3)

                    Percent_overall_DBTIME_used,

                 -- ,ROUND(total_elapsed_secs / SUM (total_elapsed_secs) OVER (PARTITION BY NULL)*100, 3) Percent_overall_Elapsed

                 ROUND (

                      total_buf_gets

                    / SUM (total_buf_gets) OVER (PARTITION BY NULL)

                    * 100,

                    2)

                    Percent_overall_Buf_Gets_used,

                 ROUND (

                      total_disk_reads

                    / SUM (total_disk_reads) OVER (PARTITION BY NULL)

                    * 100,

                    2)

                    Pct_overall_disk_reads_used

            FROM (  SELECT s.parsing_schema_name,

                           s.sql_id,(select username from xxcpf_pm_snapshot where sql_id=s.sql_id and rownum=1) OSUSER,

                           s.module,

                           ROUND (SUM (cpu_time_delta) / 1000000) total_cpu_secs,

                           ROUND (SUM (elapsed_time_delta) / 1000000)

                              total_elapsed_secs,

                           ROUND (SUM (clwait_delta) / 1000000)

                              total_cluster_wait_secs,

                           ROUND (

                                SUM (

                                     cpu_time_delta

                                   + iowait_delta

                                   + clwait_delta

                                   + apwait_delta

                                   + ccwait_delta)

                              / 1000000)

                              total_dbtime_secs,             -- non-idle waits

                          ROUND (

                                SUM (cpu_time_delta)

                              / 1000000

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)),

                              2)

                              cpu_sec_per_exec,

                           ROUND (

                                SUM (elapsed_time_delta)

                              / 1000000

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)),

                              2)

                              elap_sec_per_exec,

                           SUM (executions_delta) execs,

                           SUM (buffer_gets_delta) total_buf_gets,

                           SUM (disk_reads_delta) total_disk_reads,

                           SUM (iowait_delta) total_iowait,

                           ROUND (

                                SUM (buffer_gets_delta)

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)))

                              buf_gets_per_exec

                      FROM dba_hist_sqlstat s, dba_hist_snapshot ss

                     WHERE     1 = 1

                           AND s.instance_number = ss.instance_number

                           AND s.snap_id = ss.snap_id

                           AND s.dbid = ss.dbid

                           AND ss.instance_number = :inst_id

                           AND ss.snap_id BETWEEN 47409 AND 48128

                           AND ss.dbid = (SELECT dbid FROM v$database)

                  GROUP BY s.parsing_schema_name, s.sql_id,s.module) mod_sql_list)

         summary_list

GROUP BY parsing_schema_name, sql_id,osuser,module

--having sum(percent_overall_buf_gets_used) > 1

order by "% CPU used" desc;



Note :


if table or view does not exist ----> means snapping not enabled 


so replace this  select username from xxcpf_pm_snapshot where sql_id=s.sql_id and rownum=1---- any string i.e 'abcd'


-------------------------------


SELECT parsing_schema_name,sql_id,osuser,module,

         SUM (total_elapsed_secs) "Elapsed secs",

         SUM (total_cpu_secs) "CPU secs",

         SUM (percent_overall_cpu_used) "% CPU used",

         SUM (total_dbtime_secs) "DBTIME secs",

         SUM (percent_overall_dbtime_used) "% DBTIME used",

         SUM (total_buf_gets) "Buffer Gets",

         SUM (percent_overall_buf_gets_used) "% Buffer Gets",

         SUM (total_disk_reads) "Disk Reads",

         SUM (pct_overall_disk_reads_used) "% Disk Reads"

    FROM (SELECT mod_sql_list.*,

                 SUM (total_cpu_secs) OVER (PARTITION BY NULL)

                    overall_cpu_time_used,

                 SUM (total_dbtime_secs) OVER (PARTITION BY NULL)

                    overall_dbtime_used,

                 --  SUM (total_elapsed_secs) OVER (PARTITION BY NULL)   overall_elapsed_time_used,

                 ROUND (

                      total_cpu_secs

                    / SUM (total_cpu_secs) OVER (PARTITION BY NULL)

                    * 100,

                    3)

                    Percent_overall_CPU_used,

                 ROUND (

                      total_dbtime_secs

                    / SUM (total_dbtime_secs) OVER (PARTITION BY NULL)

                    * 100,

                    3)

                    Percent_overall_DBTIME_used,

                 -- ,ROUND(total_elapsed_secs / SUM (total_elapsed_secs) OVER (PARTITION BY NULL)*100, 3) Percent_overall_Elapsed

                 ROUND (

                      total_buf_gets

                    / SUM (total_buf_gets) OVER (PARTITION BY NULL)

                    * 100,

                    2)

                    Percent_overall_Buf_Gets_used,

                 ROUND (

                      total_disk_reads

                    / SUM (total_disk_reads) OVER (PARTITION BY NULL)

                    * 100,

                    2)

                    Pct_overall_disk_reads_used

            FROM (  SELECT s.parsing_schema_name,

                           s.sql_id,('abcd') OSUSER, -----------

                           s.module,

                           ROUND (SUM (cpu_time_delta) / 1000000) total_cpu_secs,

                           ROUND (SUM (elapsed_time_delta) / 1000000)

                              total_elapsed_secs,

                           ROUND (SUM (clwait_delta) / 1000000)

                              total_cluster_wait_secs,

                           ROUND (

                                SUM (

                                     cpu_time_delta

                                   + iowait_delta

                                   + clwait_delta

                                   + apwait_delta

                                   + ccwait_delta)

                              / 1000000)

                              total_dbtime_secs,             -- non-idle waits

                          ROUND (

                                SUM (cpu_time_delta)

                              / 1000000

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)),

                              2)

                              cpu_sec_per_exec,

                           ROUND (

                                SUM (elapsed_time_delta)

                              / 1000000

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)),

                              2)

                              elap_sec_per_exec,

                           SUM (executions_delta) execs,

                           SUM (buffer_gets_delta) total_buf_gets,

                           SUM (disk_reads_delta) total_disk_reads,

                           SUM (iowait_delta) total_iowait,

                           ROUND (

                                SUM (buffer_gets_delta)

                              / DECODE (SUM (executions_delta),

                                        0, -1,

                                        SUM (executions_delta)))

                              buf_gets_per_exec

                      FROM dba_hist_sqlstat s, dba_hist_snapshot ss

                     WHERE     1 = 1

                           AND s.instance_number = ss.instance_number

                           AND s.snap_id = ss.snap_id

                           AND s.dbid = ss.dbid

                           AND ss.instance_number = :inst_id

                           AND ss.snap_id BETWEEN 12417 AND 12563

                           AND ss.dbid = (SELECT dbid FROM v$database)

                  GROUP BY s.parsing_schema_name, s.sql_id,s.module) mod_sql_list)

         summary_list

GROUP BY parsing_schema_name, sql_id,osuser,module

--having sum(percent_overall_buf_gets_used) > 1

order by "% CPU used" desc;




------------------

and then give begin snap i.e and inst id ----- 1


select * from dba_hist_snapshot where trunc(Begin_interval_time)=to_date('11/05/2020' , 'DD/MM/YYYY')----- begin_interval_time------ 12417


select * from dba_hist_snapshot where trunc(Begin_interval_time)=to_date('14/05/2020' , 'DD/MM/YYYY')-----begin_interval_time------- 12563

 

------------------------------------------------------------------------------------------------------------------------------------------

With clause :

-------------


PLAN_TABLE_OUTPUT

SQL_ID 4byampbbvt3r9

--------------------

WITH TEMP AS (SELECT /*+ materialize*/ LOCATION_CODE, ORGANIZATION_ID 

FROM APPS.XXCTS_OM_LOCATION_V) SELECT /*+ leading(MMT) cardinality(MMT 

400) index(XORGS_T XXCTS_PLAN_INTERFACED_ORGS_U2)  */ XITEMS.ITEM_NAME, 

LOC.LOCATION_CODE || '_S', LOC1.LOCATION_CODE || '_L', L.ATTRIBUTE6, 

'R', ABS (MMT.TRANSACTION_QUANTITY), MMT.TRANSACTION_DATE, 

MMT.TRANSACTION_ID FROM MTL_SECONDARY_INVENTORIES MSUB, 

XXCTS_PLAN_INTERFACED_ORGS XORGS_T, XXCTS_PLAN_INTERFACED_ORGS XORGS, 

XXCTS_PLAN_INTERFACED_ITEMS XITEMS, TEMP LOC, TEMP LOC1, 

OE_TRANSACTION_TYPES_ALL OET, MTL_TRANSACTION_TYPES MTT, 

OE_ORDER_HEADERS_ALL H, OE_ORDER_LINES_ALL L, MTL_MATERIAL_TRANSACTIONS 

MMT WHERE MMT.TRANSACTION_REFERENCE = TO_CHAR (H.HEADER_ID) AND 

MMT.SOURCE_LINE_ID = L.LINE_ID AND L.HEADER_ID = H.HEADER_ID AND 

OET.TRANSACTION_TYPE_ID = H.ORDER_TYPE_ID AND OET.CONTEXT = 'ORDER' AND 

OET.ATTRIBUTE15 = :B6 AND MTT.TRANSACTION_TYPE_ID = 

MMT.TRANSACTION_TYPE_ID AND MTT.TRANSACTION_TYPE_NAME IN (:B5 , :B4 ) 

AND MMT.INVENTORY_ITEM_ID = XITEMS.INVENTORY_ITEM_ID AND 

XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID = XITEMS.ORGANIZATION_ID AND UPPER 

(XITEMS.EXTERNAL_APPLICATION) = :B3 AND MMT.ORGANIZATION_ID = 

LOC.ORGANIZATION_ID AND MMT.ORGANIZATION_ID = XORGS.ORGANIZATION_ID AND 

UPPER (XORGS.EXTERNAL_APPLICATION) = :B3 AND 

MMT.TRANSFER_ORGANIZATION_ID = LOC1.ORGANIZATION_ID AND 

MMT.TRANSFER_ORGANIZATION_ID = XORGS_T.ORGANIZATION_ID AND UPPER 

(XORGS_T.EXTERNAL_APPLICATION) = :B3 AND UPPER 

(XORGS_T.SOURCE_LOCATION_FLAG) = 'L' AND TO_TIMESTAMP ( TO_CHAR 

(MMT.LAST_UPDATE_DATE, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY 

HH24:MI:SS') > TO_TIMESTAMP (:B2 , 'MM/DD/YYYY HH24:MI:SS') AND 

TO_TIMESTAMP ( TO_CHAR (MMT.LAST_UPDATE_DATE, 'MM/DD/YYYY HH24:MI:SS'), 

'MM/DD/YYYY HH24:MI:SS') <= TO_TIMESTAMP ( TO_CHAR (:B1 , 'MM/DD/YYYY 

HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS') AND MMT.TRANSACTION_QUANTITY < 0 

AND MSUB.ORGANIZATION_ID = MMT.ORGANIZATION_ID AND 

MSUB.SECONDARY_INVENTORY_NAME = MMT.SUBINVENTORY_CODE AND 

MSUB.AVAILABILITY_TYPE = 1 AND EXISTS (SELECT NULL FROM CSD_REPAIRS CR, 

PO_REQUISITION_LINES_ALL PRL, OE_TRANSACTION_TYPES_TL LT, 

OE_ORDER_LINES_ALL SOL WHERE CR.REPAIR_NUMBER = L.ATTRIBUTE6 AND 

LT.TRANSACTION_TYPE_ID = SOL.LINE_TYPE_ID AND LT.LANGUAGE = USERENV 

('LANG') AND SOL.SOURCE_DOCUMENT_LINE_ID = PRL.REQUISITION_LINE_ID AND 

LT.NAME LIKE 'SERVICE RPR%' AND PRL.SOURCE_ORGANIZATION_ID = 

CR.RETURN_ATTRIBUTE3 AND PRL.SOURCE_SUBINVENTORY = 

XXCTS_RPR_CSD_COMMON_UTILITY.GET_SUB_INVENTORY ( 'SOURCE', TO_NUMBER 

(CR.RETURN_ATTRIBUTE3), 'SERVICE REPAIR') AND 

PRL.DESTINATION_ORGANIZATION_ID = CR.RETURN_ATTRIBUTE4 AND 

PRL.DESTINATION_SUBINVENTORY = XXCTS_RPR_CSD_COMMON_UTILITY.GET_SUB_INVE

NTORY ( 'DESTINATION', TO_NUMBER (CR.RETURN_ATTRIBUTE4), 'SERVICE 

REPAIR')) UNION SELECT /*+ leading(MMT) cardinality(MMT 400) 

index(XORGS_T XXCTS_PLAN_INTERFACED_ORGS_U2)  */ XITEMS.ITEM_NAME, 

LOC.LOCATION_CODE || '_S' LOCATION_CODE, LOC1.LOCATION_CODE || '_L' 

LOCATION_CODE1, L.REFERENCE, 'R', ABS (MMT.TRANSACTION_QUANTITY), 

MMT.TRANSACTION_DATE, MMT.TRANSACTION_ID FROM 

XXCTS_PLAN_INTERFACED_ORGS XORGS_T, XXCTS_PLAN_INTERFACED_ORGS XORGS, 

XXCTS_PLAN_INTERFACED_ITEMS XITEMS, TEMP LOC, TEMP LOC1, MFG_LOOKUPS 

MFG, MTL_TRANSACTION_TYPES MTT, MTL_TXN_REQUEST_HEADERS H, 

MTL_TXN_REQUEST_LINES L, MTL_MATERIAL_TRANSACTIONS MMT WHERE 

MMT.SOURCE_LINE_ID = L.LINE_ID AND L.HEADER_ID = H.HEADER_ID AND 

MFG.LOOKUP_TYPE = 'MOVE_ORDER_TYPE' AND MFG.LOOKUP_CODE = 

H.MOVE_ORDER_TYPE AND MTT.TRANSACTION_TYPE_ID = MMT.TRANSACTION_TYPE_ID 

AND MTT.TRANSACTION_TYPE_NAME IN (:B7 ) AND MMT.INVENTORY_ITEM_ID = 

XITEMS.INVENTORY_ITEM_ID AND XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID = 

XITEMS.ORGANIZATION_ID AND UPPER (XITEMS.EXTERNAL_APPLICATION) = :B3 

AND MMT.ORGANIZATION_ID = LOC.ORGANIZATION_ID AND MMT.ORGANIZATION_ID = 

XORGS.ORGANIZATION_ID AND UPPER (XORGS.EXTERNAL_APPLICATION) = :B3 AND 

MMT.TRANSFER_ORGANIZATION_ID = LOC1.ORGANIZATION_ID AND 

MMT.TRANSFER_ORGANIZATION_ID = XORGS_T.ORGANIZATION_ID AND UPPER 

(XORGS_T.SOURCE_LOCATION_FLAG) = 'L' AND UPPER 



----------------------- Script to genetare sql profile ------------------------click F5 pass sql id and plan hash


--NEW modified script for sql profile 2015-07-30

--Remember to check the Child Number from gv$sql_plan 

--Inputs are SQL ID and Child Number from gv$sql_plan

-- Do not delete or change any of the following text --


set pagesize 0

set line 1999

set verify off;

set TRIMOUT ON;

set heading off;

set feedback off;

set echo off;

--def sql_id = &&sql_id_value

--def child_number = &&child_number_value

--def plan_hash_valve=&&plan_hash_value




SELECT    '--This Script will generate SQL PROFILE for SQL ID: '

       || '&&SQL_ID'

       || CHR (10)

  FROM DUAL;


SELECT CHR (10) || 'Define SQL_ID =' || '''' || '&&SQL_ID' || '''' || ';'

  FROM DUAL;


SELECT    CHR (10)

       || 'DECLARE'

       || CHR (10)

       || 'clsql_text CLOB;'

       || CHR (10)

       || CHR (10)

       || 'BEGIN'

       || CHR (10)

       || CHR (10)

       || 'SELECT sql_text INTO clsql_text FROM dba_hist_sqltext where sql_id ='

       || ''''

       || '&&SQL_ID'

       || ''''

       || ';'

       || CHR (10)

  FROM DUAL;


SELECT    CHR (10)

       || 'dbms_sqltune.import_sql_profile(sql_text => clsql_text,'

       || CHR (10)

       || CHR (9)

       || 'profile=> sqlprof_attr('

       || CHR (10)

       || CHR (9)

       || '''BEGIN_OUTLINE_DATA'','

       || CHR (10)

  FROM DUAL;

  

SELECT    CHR (9)

       || ''''

       || REGEXP_REPLACE (EXTRACTVALUE (VALUE (d), '/hint'), '''', '''''')

       || ''','

  FROM XMLTABLE (

          '/*/outline_data/hint'

          PASSING (SELECT xmltype (other_xml) AS xmlval

                     FROM dba_hist_sql_plan

                    WHERE     sql_id = '&&SQL_ID'

                          AND plan_hash_value = '&&plan_hash_value'

                          AND other_xml IS NOT NULL)) d;

                        

SELECT    CHR (9)

       || '''END_OUTLINE_DATA'''

       || '),'

       || CHR (10)

       || 'name =>'

       || '''PROFILE_'

       || '&&SQL_ID'

       || ''''

       || ','

       || CHR (10)

       || 'force_match=>true);'

  FROM DUAL;            

  

SELECT 

           CHR (10)

       || 'END;'

       || CHR (10)

       || '/'

  FROM DUAL;        


select CHR(10) from dual;


===== one more script to generate sql profile


--NEW modified script for sql profile 2015-07-30

--Remember to check the Child Number from gv$sql_plan 

--Inputs are SQL ID and Child Number from gv$sql_plan

-- Do not delete or change any of the following text --


set pagesize 0

set line 1999

set verify off;

SET TRIMOUT ON

set heading off;

set feedback off;

set echo off;

--def sql_id = &&sql_id_value

def child_number = &&child_number_value



SELECT    '--This Script will generate SQL PROFILE for SQL ID: '

       || '&&SQL_ID'

       || CHR (10)

  FROM DUAL;


SELECT CHR (10) || 'Define SQL_ID =' || '''' || '&&SQL_ID' || '''' || ';'

  FROM DUAL;


SELECT    CHR (10)

       || 'DECLARE'

       || CHR (10)

       || 'clsql_text CLOB;'

       || CHR (10)

       || CHR (10)

       || 'BEGIN'

       || CHR (10)

       || CHR (10)

       || 'SELECT sql_text INTO clsql_text FROM GV$sql where sql_id ='

       || ''''

       || '&&SQL_ID'

       || ''''

       || ';'

       || CHR (10)

  FROM DUAL;


SELECT    CHR (10)

       || 'dbms_sqltune.import_sql_profile(sql_text => clsql_text,'

       || CHR (10)

       || CHR (9)

       || 'profile=> sqlprof_attr('

       || CHR (10)

       || CHR (9)

       || '''BEGIN_OUTLINE_DATA'','

       || CHR (10)

  FROM DUAL;

  

SELECT    CHR (9)

       || ''''

       || REGEXP_REPLACE (EXTRACTVALUE (VALUE (d), '/hint'), '''', '''''')

       || ''','

  FROM XMLTABLE (

          '/*/outline_data/hint'

          PASSING (SELECT xmltype (other_xml) AS xmlval

                     FROM gv$sql_plan

                    WHERE     sql_id = '&&SQL_ID'

                          AND CHILD_NUMBER = '&&child_number'

                          AND other_xml IS NOT NULL)) d;

                        

SELECT    CHR (9)

       || '''END_OUTLINE_DATA'''

       || '),'

       || CHR (10)

       || 'name =>'

       || '''PROFILE_'

       || '&&SQL_ID'

       || ''''

       || ','

       || CHR (10)

       || 'force_match=>true);'

  FROM DUAL;            

  

SELECT 

           CHR (10)

       || 'END;'

       || CHR (10)

       || '/'

  FROM DUAL;        


select CHR(10) from dual;



====== other script for sql profile


DECLARE

   ar_profile_xml   CLOB;

   cl_sql_text      CLOB;

BEGIN

   -- get source sql_id  information from good plan

   --

   SELECT REGEXP_REPLACE (other_xml,

                          '.*(<outline_data>.*</outline_data>).*',

                          '\1')

     INTO ar_profile_xml

     FROM dba_hist_sql_plan

    WHERE     sql_id = '7g2979vus3h6d'

          AND PLAN_HASH_VALUE = 3111136292--source SQL_ID with good plan

          AND child_number = 0

          AND other_xml IS NOT NULL

          AND ROWNUM = 1;


   -- get information of target sql_id

   -- 

   

   BEGIN

      SELECT sql_fulltext

        INTO cl_sql_text

        FROM dba_hist_sqltext

       WHERE sql_id = '0ajb70dnwntwz';

   EXCEPTION

      WHEN NO_DATA_FOUND

      THEN

         SELECT sql_text

           INTO cl_sql_text

           FROM dba_hist_sqltext

          WHERE     sql_id = '0ajb70dnwntwz'

                AND dbid = (SELECT dbid FROM gv$database);

   END;


   -- fix Profile

   DBMS_SQLTUNE.import_sql_profile (

      sql_text      => cl_sql_text,

      profile_xml   => ar_profile_xml,

      name          => 'PROFILE_0ajb70dnwntwz',

      force_match   => TRUE);

END;


=============== way to generate sql profile script


SQL> @coe_xfr_sql_profile.sql


Parameter 1:

SQL_ID (required)


Enter value for 1: 9m4fshxh5azcb



PLAN_HASH_VALUE AVG_ET_SECS

--------------- -----------

     3082536350   65908.371

     3884177337  110866.762

      528415816  112863.198

       95515781  126667.717


Parameter 2:

PLAN_HASH_VALUE (required)


Enter value for 2: 3082536350


Values passed:

~~~~~~~~~~~~~

SQL_ID         : "9m4fshxh5azcb"

PLAN_HASH_VALUE: "3082536350"



Execute coe_xfr_sql_profile_9m4fshxh5azcb_3082536350.sql on TARGET system in order to create a custom SQL Profile with plan 3082536350 linked to adjusted sql_text.



COE_XFR_SQL_PROFILE completed.


====== query to get optimizer hints or scaling


set serveroutput on echo off

declare

  -- input variables

  input_task_owner dba_advisor_tasks.owner%type:='&task_owner';

  input_task_name dba_advisor_tasks.task_name%type:='&task_name';

  input_show_outline boolean:=false;

  -- local variables

  task_id  dba_advisor_tasks.task_id%type;

  outline_data xmltype;

  benefit number;

begin

  for o in ( select * from dba_advisor_objects where owner=input_task_owner and task_name=input_task_name and type='SQL')

  loop

          -- get the profile hints (opt_estimate)

          dbms_output.put_line('--- PROFILE HINTS from '||o.task_name||' ('||o.object_id||') statement '||o.attr1||':');

          dbms_output.put_line('/*+');

          for r in (

            select hint,benefit from (

             select case when attr5 like 'OPT_ESTIMATE%' then cast(attr5 as varchar2(4000)) when attr1 like 'OPT_ESTIMATE%' then attr1 end hint,benefit

             from dba_advisor_recommendations t join dba_advisor_rationale r using (task_id,rec_id)

             where t.owner=o.owner and t.task_name = o.task_name and r.object_id=o.object_id and t.type='SQL PROFILE'

             --and r.message='This attribute adjusts optimizer estimates.'

            ) order by to_number(regexp_replace(hint,'^.*=([0-9.]+)[^0-9].*$','\1'))

          ) loop

           dbms_output.put_line('   '||r.hint); benefit:=to_number(r.benefit)/100;

          end loop;

          dbms_output.put_line('*/');

          -- get the outline hints

          begin

          select outline_data into outline_data from (

              select case when other_xml is not null then extract(xmltype(other_xml),'/*/outline_data/hint') end outline_data

              from dba_advisor_tasks t join dba_sqltune_plans p using (task_id)

              where t.owner=o.owner and t.task_name = o.task_name and p.object_id=o.object_id  and t.advisor_name='SQL Tuning Advisor' --11gonly-- and execution_type='TUNE SQL'

              and p.attribute='Using SQL profile'

          ) where outline_data is not null;

          exception when no_data_found then null;

          end;

          exit when not input_show_outline;

          dbms_output.put_line('--- OUTLINE HINTS from '||o.task_name||' ('||o.object_id||') statement '||o.attr1||':');

          dbms_output.put_line('/*+');

          for r in (

              select (extractvalue(value(d), '/hint')) hint from table(xmlsequence(extract( outline_data , '/'))) d

          ) loop

           dbms_output.put_line('   '||r.hint);

          end loop;

          dbms_output.put_line('*/');

          dbms_output.put_line('--- Benefit: '||to_char(to_number(benefit),'FM99.99')||'%');

  end loop;

  dbms_output.put_line('');

end;

/


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


Note :

------

pass sql id and PHV


TO check sql profile deployed or not and picking or not

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


select * from dba_sql_profiles where name like 'PROFILE_6f72pu9v2psdr'



select * from gv$sql where sql_id='6f72pu9v2psdr'



select * from dba_sql_profiles where name like 'PROFILE_dnvmd979qnnfv'



select * from gv$sql where sql_id='dnvmd979qnnfv'


copy output of the script and give it as sql profile (remove if any space when starting with '')

--------------------------------------------------------------------------------------------------------------------------------------------------------------



select /*+parallel(32)*/RUN_STATUS,count(*)

from WFPUBLISH.XXDH_OUTBOUND_REQUESTS

group by RUN_STATUS

order by 2 desc


execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30);


SELECT RECORD_STATUS,COMMENTS

FROM WFPUBLISH.XXDH_ATS_JOBTITLE_MAPPING_STG

WHERE REQUEST_ID IN

(SELECT REQUEST_ID

FROM WFPUBLISH.XXDH_OUTBOUND_REQUESTS

WHERE RUN_STATUS = 'R'

AND TRUNC (START_DATE) < TRUNC (SYSDATE))

AND RECORD_STATUS = 'N'




SOURCE_DATABASE_NAME SOURCE_SCHEMA_NAME TARGET_DATABASE_NAME TARGET_SCHEMA_NAME DB_LINK_NAME

DV1CFS XXCFSFND CFSPRD XXCFSPRC QUOTEADM

DV1CFS XXCFSFND CG1PRD_SRVC_OTH APPSRO CG1

DV1CFS XXCFSFND CLFPRD APPSRO APPSRO

DV1CFS XXCFSFND CLFPRD APPSRO XXCFSFND_CLFPRD_APPSRO

DV1CFS XXCFSFND CLFPRD XXCLFST TS2CLF

DV1CFS XXCFSFND CLFPRD XXCLFST XXCFSFND_CLFPRD_XXCLFST

DV1CFS XXCFSFND CLFPRD XXCLFST XXCLFST

DV1CFS XXCFSFND CRTPRD XXNGCR_RO CRTPRD

DV1CFS XXCFSFND FNTR2PRD CSC_MIDAS CSC_MIDAS

DV1CFS XXCFSPRC DMPROD XXQ2O_CPS_U CSCMDMLINK

DV1CFS XXCFSPRC FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM

DV1CFS XXCFSPRC FNTR2PRD QUOTEADM QUOTEADM

DV1CFS XXCFSQ2A CLFPRD APPSRO CLF

DV1CFS XXCFSQ2A ESALESPD SFA_READ ESALES

DV1CFS XXCFSQ2A FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM

DV1CFS XXCFSQ2A FNTR2PRD ELESEUSR ELESEUSR

DV1CLF APPS CLFPRD APPSRO XXCLF_CLFPRD_DV1_ROUSER

DV1CLF XXCLF FNTR2PRD READONLYUSER XXCLF_FNTR2PRD_TREASURY_ROUSER




CREATE table XXDH_OUTBOUND_REQUESTS_TEMP as select * from WFPUBLISH.XXDH_OUTBOUND_REQUESTS


create index RUN_STATUS_IDX on XXDH_OUTBOUND_REQUESTS_TEMP(RUN_STATUS)


execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30);



SELECT NVL (COUNT (1), 0)

  FROM XXICM.XXICM_TRANS_LOAD_TRACKING

 WHERE     TABLE_NAME = :B4

       AND PARENT_REQUEST_ID = NVL (:B3, PARENT_REQUEST_ID)

       AND NVL (STATUS, 'N') = 'R'

       AND NVL (ORG_ID, 1) = NVL (:B2, 1)

       AND NVL (DATA_SOURCE, 'ZZZ') = NVL (:B1, 'ZZZ')

   

   16354 cr 

   16440  after index and histogram

   

   

     

CREATE INDEX XXCTS_COMP_INV_NO_TRM ON XXCTS_COMP_EXP_LINES_TEAMP

(TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID"))


CREATE INDEX XXCTS_COMP_LINES_TPL_HDR ON XXCTS_COMP_EXP_LINES_TEAMP

(TPL_HDR_ID)


CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK ON XXCTS_COMP_EXP_LINES_TEAMP

(INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11)




Hi All,

The Top SQL reports, Host Analysis & the MOM can also be found at  http://prfrcdn-prd-1:8080/perf_mon/

 

Points Discussed:

Top SQL analysis for time period 27-Mar-2020 to 21-Apr-2020


              APPS Report: 

No Problematic SQLs found. 


DB Report

No SQLs identified as problematic for case creation.


DB Link Report

No issues observed.


Wait event Report: 

No Problematic SQLs found. 


Action on Perf Team:

NA

Action on App team:

NA

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


https://examv2.cloudapps.cisco.com/extranet/ExAMV2/nsrhomepagereq.action


https://dbaas.cisco.com/AllAboutDB/home#/dbDown/ ------------Db List Link




create table EXP_LINES_TEMP3 as select * from XXCTS_O.XXCTS_COMP_EXP_LINES



CREATE INDEX PT_NO_IDX ON EXP_LINES_TEMP3(TRIM("PART_NO"))



SELECT /*+INDEX(A PT_NO_IDX)*/ NVL (HTS_SCHEDULE_B_NO, NULL)

  FROM EXP_LINES_TEMP3 A, XXCCS_BOP_O.XXCCS_BOP_OE_SHIPMENT_LINES SHPLNS

 WHERE     TRIM (A.INVOICE_NO) = SHPLNS.DELIVERY_ID

       AND TRIM (A.PART_NO) = :B2

       AND TRIM (TO_CHAR (A.DELIVERY_DETAIL_ID)) = SHPLNS.DELIVERY_DETAIL_ID

       AND PROCESS_CODE = 'OUTBOUND'

       AND :B1 = SHPLNS.DELIVERY_ID

       

       

CREATE INDEX XXCTS_COMP_INV_NO_TRM1 ON EXP_LINES_TEMP3

(TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID")))


CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK1 ON EXP_LINES_TEMP3

(INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11)


--------------------------------------------------------------


CREATE table OTMM_JOB_EXECUTION_TEMP as select * from OTMMCORE.OTMM_JOB_EXECUTION


create index PARENT_JOB_INSTANCE_ID_INDX on OTMM_JOB_EXECUTION_TEMP(PARENT_JOB_INSTANCE_ID)


CREATE table COM_ORDER_MAPPER_T as select * from COMUSER.COM_ORDER_MAPPER where rownum<1000000


create index IDX_COM_ORDER_MAPPER_T on COM_ORDER_MAPPER_T(status)



SELECT /*+ INDEX(A PARENT_JOB_INSTANCE_ID_INDX)*/ JOB_EXECUTION_ID, JOB_INSTANCE_ID, STATUS

  FROM OTMM_JOB_EXECUTION_TEMP A

 WHERE PARENT_JOB_INSTANCE_ID = :1 ------->Index  Range Scan

 

 --------------------------------------------------------------------------------------------------------------------------------

 

 

 This case has been created through ExAM V2 for UBVPN Account Creation 


Partner Name: TCS (aka Tata Consultancy Services)

Partner Site Known Name: tcs10-in

Location: 801, 901, & 1001 KENSINGTON 'A' WING HIRANANDANI BUILDERS SPECIAL ECONOMIC ZONE POWAI,Mumbai,Maharashtra,INDIA

Business Function: IT Applications Development

Business Sponsor ID: rdharmen

Billing Dept No: 020071578

List of Users to be created: 

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

User ID: makancha

User Name: Madan Kumar Kancharla

Manager Approved ID: ywadhavk

Manager Approved Date: 04/16/2020



Hi Manish 


Thanks for contacting accounts team 


Account migration is completed. The next token generated will allow you to connect GEM cluster(bgl13-gem-ubvpn-gw1a.cisco.com / bgl13-gem-ubvpn-gw2a.cisco.com ). 


In the future, if the password prompt loops please get new passwords until one is accepted. 


I am marking the case as resolved but it can be reopened within 5 days. 

ESP system will close the case at the 5 day mark and it cannot be re-opened. 

However, if there is still an issue, please contact me (ppenumat@cisco.com) and I will be happy to further assist you. 


"HOW TO REOPEN YOUR TICKET WITHIN 5 DAYS" - https://cisco.service-now.com/sp?id=kb_article&sys_id=9a8a31e3dbfbef4039fe9c9adb96198c 


We would love to hear your experience in the manner the incident was managed. Please share your feedback online or via an Email to my manager (lognagar@cisco.com). 

Also, share any areas of opportunity (if any) to improve the remote support service. 


Regards 

Prudhvi raj



=============== josh arora

set linesize 750 pages 9999

column box format a30

column spid format a10

column username format a30 

column program format a30

column os_user format a20

col LOGON_TIME for a20  


select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time,

 substr(b.username,1,30) username,

 substr(b.osuser,1,20) os_user,

 substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id 

 from gv$session b,gv$process a 

 where b.paddr = a.addr 

 and a.inst_id = b.inst_id  

 and type='USER' and b.status='ACTIVE'

 order by logon_time;

 

=============== https://ardentperf.com/2007/09/12/gc-buffer-busy-waits-in-rac-finding-hot-blocks/

 

select min(begin_interval_time) min, max(end_interval_time) max 

from dba_hist_snapshot

where snap_id between 129615 and 129616;



select wait_class_id, wait_class, count(*) cnt 

from dba_hist_active_sess_history

where snap_id between 129615 and 129616

group by wait_class_id, wait_class

order by 3;


select event_id, event, count(*) cnt from dba_hist_active_sess_history

where snap_id between 129615 and 129616 and wait_class_id=3871361733

group by event_id, event

order by 3;


select sql_id, count(*) cnt from dba_hist_active_sess_history

where snap_id between 129615 and 129615

and event_id in (2701629120,1520064534)

group by sql_id

order by 2;



select sql_text from dba_hist_sqltext where sql_id='5w6vqmyy956cc';


select count(distinct(current_obj#)) from dba_hist_active_sess_history

where snap_id between 129615 and 129615 

and event_id=1520064534 and sql_id='5w6vqmyy956cc';



 

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

 

 SELECT instance_number, sql_opname,event, p1, p2, p3,  current_obj#,  COUNT (*) cnt

FROM dba_hist_active_sess_history

WHERE sample_time BETWEEN TIMESTAMP '2020-11-24 6:30:04'

      AND TIMESTAMP '2020-11-24 7:30:14'

  AND wait_class = 'Cluster'

GROUP BY instance_number, event, sql_opname,p1, p2, p3, current_obj#

ORDER BY cnt DESC

 /

 

SELECT sql_id, SQL_PLAN_HASH_VALUE, SQL_PLAN_LINE_ID, COUNT (*) cnt

FROM dba_hist_active_sess_history h

WHERE  sample_time BETWEEN TIMESTAMP '2020-11-24 6:30:04'

       AND TIMESTAMP '2020-11-24 7:30:14'

  AND wait_class = 'Cluster' and event='gc buffer busy acquire'

GROUP BY sql_id, SQL_PLAN_HASH_VALUE, SQL_PLAN_LINE_ID

ORDER BY cnt DESC;


select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ALL'));



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


https://examv2.cloudapps.cisco.com/extranet/ExAMV2/nsrhomepagereq.action


https://dbaas.cisco.com/AllAboutDB/home#/dbDown/ ------------Db List Link




create table EXP_LINES_TEMP3 as select * from XXCTS_O.XXCTS_COMP_EXP_LINES



CREATE INDEX PT_NO_IDX ON EXP_LINES_TEMP3(TRIM("PART_NO"))



SELECT /*+INDEX(A PT_NO_IDX)*/ NVL (HTS_SCHEDULE_B_NO, NULL)

  FROM EXP_LINES_TEMP3 A, XXCCS_BOP_O.XXCCS_BOP_OE_SHIPMENT_LINES SHPLNS

 WHERE     TRIM (A.INVOICE_NO) = SHPLNS.DELIVERY_ID

       AND TRIM (A.PART_NO) = :B2

       AND TRIM (TO_CHAR (A.DELIVERY_DETAIL_ID)) = SHPLNS.DELIVERY_DETAIL_ID

       AND PROCESS_CODE = 'OUTBOUND'

       AND :B1 = SHPLNS.DELIVERY_ID

       

       

CREATE INDEX XXCTS_COMP_INV_NO_TRM1 ON EXP_LINES_TEMP3

(TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID")))


CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK1 ON EXP_LINES_TEMP3

(INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11)


--------------------------------------------------------------


CREATE table OTMM_JOB_EXECUTION_TEMP as select * from OTMMCORE.OTMM_JOB_EXECUTION


create index PARENT_JOB_INSTANCE_ID_INDX on OTMM_JOB_EXECUTION_TEMP(PARENT_JOB_INSTANCE_ID)



SELECT /*+ INDEX(A PARENT_JOB_INSTANCE_ID_INDX)*/ JOB_EXECUTION_ID, JOB_INSTANCE_ID, STATUS

  FROM OTMM_JOB_EXECUTION_TEMP A

 WHERE PARENT_JOB_INSTANCE_ID = :1 ------->Index  Range Scan

 

 --------------------------------------------------------------------------------------------------------------------------------

 

 

 This case has been created through ExAM V2 for UBVPN Account Creation 


Partner Name: TCS (aka Tata Consultancy Services)

Partner Site Known Name: tcs10-in

Location: 801, 901, & 1001 KENSINGTON 'A' WING HIRANANDANI BUILDERS SPECIAL ECONOMIC ZONE POWAI,Mumbai,Maharashtra,INDIA

Business Function: IT Applications Development

Business Sponsor ID: rdharmen

Billing Dept No: 020071578

List of Users to be created: 

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

User ID: makancha

User Name: Madan Kumar Kancharla

Manager Approved ID: ywadhavk

Manager Approved Date: 04/16/2020



Hi Manish 


Thanks for contacting accounts team 


Account migration is completed. The next token generated will allow you to connect GEM cluster(bgl13-gem-ubvpn-gw1a.cisco.com / bgl13-gem-ubvpn-gw2a.cisco.com ). 


In the future, if the password prompt loops please get new passwords until one is accepted. 


I am marking the case as resolved but it can be reopened within 5 days. 

ESP system will close the case at the 5 day mark and it cannot be re-opened. 

However, if there is still an issue, please contact me (ppenumat@cisco.com) and I will be happy to further assist you. 


"HOW TO REOPEN YOUR TICKET WITHIN 5 DAYS" - https://cisco.service-now.com/sp?id=kb_article&sys_id=9a8a31e3dbfbef4039fe9c9adb96198c 


We would love to hear your experience in the manner the incident was managed. Please share your feedback online or via an Email to my manager (lognagar@cisco.com). 

Also, share any areas of opportunity (if any) to improve the remote support service. 


Regards 

Prudhvi raj


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


select /*+parallel(32)*/RUN_STATUS,count(*)

from WFPUBLISH.XXDH_OUTBOUND_REQUESTS

group by RUN_STATUS

order by 2 desc



drop index index name 


drop table table name 


create histogram on column RUN_STATUS :


execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30);


To drop histogram :


BEGIN

 dbms_stats.Delete_column_stats(ownname => 'PERF11I', tabname => 'DIST_T',

 colname => 'LEDGER_ID', col_stat_type => 'HISTOGRAM');

END;

/


SELECT RECORD_STATUS,COMMENTS

FROM WFPUBLISH.XXDH_ATS_JOBTITLE_MAPPING_STG

WHERE REQUEST_ID IN

(SELECT REQUEST_ID

FROM WFPUBLISH.XXDH_OUTBOUND_REQUESTS

WHERE RUN_STATUS = 'R'

AND TRUNC (START_DATE) < TRUNC (SYSDATE))

AND RECORD_STATUS = 'N'




SOURCE_DATABASE_NAME SOURCE_SCHEMA_NAME TARGET_DATABASE_NAME TARGET_SCHEMA_NAME DB_LINK_NAME

DV1CFS XXCFSFND CFSPRD XXCFSPRC QUOTEADM

DV1CFS XXCFSFND CG1PRD_SRVC_OTH APPSRO CG1

DV1CFS XXCFSFND CLFPRD APPSRO APPSRO

DV1CFS XXCFSFND CLFPRD APPSRO XXCFSFND_CLFPRD_APPSRO

DV1CFS XXCFSFND CLFPRD XXCLFST TS2CLF

DV1CFS XXCFSFND CLFPRD XXCLFST XXCFSFND_CLFPRD_XXCLFST

DV1CFS XXCFSFND CLFPRD XXCLFST XXCLFST

DV1CFS XXCFSFND CRTPRD XXNGCR_RO CRTPRD

DV1CFS XXCFSFND FNTR2PRD CSC_MIDAS CSC_MIDAS

DV1CFS XXCFSPRC DMPROD XXQ2O_CPS_U CSCMDMLINK

DV1CFS XXCFSPRC FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM

DV1CFS XXCFSPRC FNTR2PRD QUOTEADM QUOTEADM

DV1CFS XXCFSQ2A CLFPRD APPSRO CLF

DV1CFS XXCFSQ2A ESALESPD SFA_READ ESALES

DV1CFS XXCFSQ2A FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM

DV1CFS XXCFSQ2A FNTR2PRD ELESEUSR ELESEUSR

DV1CLF APPS CLFPRD APPSRO XXCLF_CLFPRD_DV1_ROUSER

DV1CLF XXCLF FNTR2PRD READONLYUSER XXCLF_FNTR2PRD_TREASURY_ROUSER




CREATE table XXDH_OUTBOUND_REQUESTS_TEMP as select * from WFPUBLISH.XXDH_OUTBOUND_REQUESTS


create index RUN_STATUS_IDX on XXDH_OUTBOUND_REQUESTS_TEMP(RUN_STATUS)


execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30);



SELECT NVL (COUNT (1), 0)

  FROM XXICM.XXICM_TRANS_LOAD_TRACKING

 WHERE     TABLE_NAME = :B4

       AND PARENT_REQUEST_ID = NVL (:B3, PARENT_REQUEST_ID)

       AND NVL (STATUS, 'N') = 'R'

       AND NVL (ORG_ID, 1) = NVL (:B2, 1)

       AND NVL (DATA_SOURCE, 'ZZZ') = NVL (:B1, 'ZZZ')

   

   16354 cr 

   16440  after index and histogram

   

***************

CREATE table am_domain_T as select * from EMANADM.am_domain where rownum <1000000


create index IDX_am_domain_T on am_domain_T(parent_domain_id)




********************

   

     

CREATE INDEX XXCTS_COMP_INV_NO_TRM ON XXCTS_COMP_EXP_LINES_TEAMP

(TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID"))


CREATE INDEX XXCTS_COMP_LINES_TPL_HDR ON XXCTS_COMP_EXP_LINES_TEAMP

(TPL_HDR_ID)


CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK ON XXCTS_COMP_EXP_LINES_TEAMP

(INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11)


DROP INDEX ord_customer_ix_demo;


create table XXODI_OE_ORDER_LINES_HISTORY_T as select * from XXODI.XXODI_OE_ORDER_LINES_HISTORY where rownum <1000000


create index HIST_TYPE_CODE_IDX1 on XXODI_OE_ORDER_LINES_HISTORY_T(HIST_CREATION_DATE,HIST_TYPE_CODE)


Hi All,

The Top SQL reports, Host Analysis & the MOM can also be found at  http://prfrcdn-prd-1:8080/perf_mon/

 

Points Discussed:

Top SQL analysis for time period 27-Mar-2020 to 21-Apr-2020


              APPS Report: 

No Problematic SQLs found. 


DB Report

No SQLs identified as problematic for case creation.


DB Link Report

No issues observed.


Wait event Report: 

No Problematic SQLs found. 


Action on Perf Team:

NA

Action on App team:

NA

====================================================== sql tuning advisary


declare

task_nm varchar2(100);

begin

task_nm := dbms_sqltune.create_tuning_task(SQL_ID=> '&SQL_ID',TASK_NAME => 'SQL_TUNNING_TASK_SQL_ID');

end;

/


SQL> SELECT task_name, status FROM dba_advisor_log WHERE task_name = '&TASK_NAME';


exec dbms_sqltune.execute_tuning_task (TASK_NAME => '&TASK_NAME');


SQL>SET LONG 10000;

SQL>SET PAGESIZE 1000

SQL>

SQL> SELECT DBMS_SQLTUNE.report_tuning_task('&TASK_NAME') AS recommendations FROM dual;

SQL>SET PAGESIZE 24


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


   Performance team - Oracle 19c upgrade Run Book 

   

Pre-Upgrade 19c Activity: 

All below activities as mentioned are used to carry out in the Non-PROD environment after 19c Upgrade:

i. First, we have to enable the snapping for all respective Non-PROD database where the application will do testing.

ii. Validate all the parameters at the database level before the environment get release to the app team.

iii. Once App team will start the testing, they will share the Start date of the testing with Perf team

iv. We used to do Top SQL analysis on periodically basis and share the analysis with app team if any SQLs identify as regressed will highlight and will provide recommendation for it.

v. As part of proactive measure, performance team used to do plan change analysis activity.

vi. As a part of proactively validation of Critical programs, will create AWR baseline for the problematic duration post upgrade 19c.

vii. As a part of proactive measure to identify the regress concurrent programs performance, will used to do concurrent program comparison analysis.

Post Upgrade 19c Activity:

All below activities as mentioned are used to carry out in the PROD environment after 19c Upgrade: 

i. Validate the snapping enablement after 19c upgrade to PROD environment.

ii. Validate the parameters at the database level.

iii. Provide normalization support after 19c upgrade for two weeks.

iv. Create AWR base creation after 19c upgrade and generate the comparison report.


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


OJVM:


https://mikedietrichde.com/2016/09/05/the-ojvm-patching-saga-and-how-to-solve-it-part-i/

Josh Arora 2/2/2021, 1:34 AM


The actual steps recommenced by oracle support are listed below -

1.Install the DBRU patch on 12.2 home

2.upgrade the database (datapatch will run during post upgrade steps)

3.Please check the upgrade log whether datapatch completed successfully or not

4.If datapatch failed during post upgrade steps please rerun the datapatch maually for the DBRU patch before installing the OJVM RU

3. Install the OJVM RU

4.Run post install steps for OJVM RU

——- end of support details – – – –

Hope this helps others too…..

Josh Arora 2/2/2021, 1:35 AM


You can use opatchauto if you are applying this OJVM patch in 12.2 now . And Yes there is no documentation about it but it is understood to be the case for RAC. Or you can apply the single patch with the opatch apply command. “And Yes there is no documentation about it”. Hm …

I disagree with the step to do the OJVM separately after the upgrade. I don’t see why this should happen just after upgrade.

Some interesting facts about OJVM

Suraj Ramchander 2/2/2021, 1:36 AM


thanks

I have asked them to reach out to oracle if it occurs again and again

Josh Arora 2/2/2021, 1:37 AM


Suraj this incident ticket # INC3035477 would be a great example for this scenario for the database G2CPRD

Kindly discuss this in the upcoming weekly meeting it s a great learning experience for everyone

Suraj Ramchander 2/2/2021, 1:38 AM


sure

Josh Arora 2/2/2021, 1:38 AM


and the pains and sagas revolving around OVJM

thanxs much great work

Josh Arora 2/2/2021, 1:39 AM


Yes reaching out to oracle is the absolute correct approach for these kind of waits as they are not clearly documented and ironically have changed in 21c release

Suraj Ramchander 2/2/2021, 1:40 AM


yeah

Josh Arora 2/2/2021, 1:40 AM


MOS Note: 1929745.1 – Oracle Recommended Patches — “Oracle JavaVM Component Database PSU and Update” (OJVM PSU and OJVM Update) Patches

I spoke to some RAC directors at oracle 15 mins ago

They recommended reading the above mentioned MOS note

Josh Arora 2/2/2021, 1:42 AM


One final question needs to remain unanswered:

Why do we deliver COMBO patches with GI and OJVM?

I have seriously no idea. And the README doesn’t shed some light here either.

Actually, the reason is that the COMBO patch delivers everything despite that fact that it’s called GI+OJVM – it has the database patch bundle included, too.

Cool stuff - back to ranch



*****


Session is not progressing for OJVM:generic wait event.


Can you please restart your application

because the cause: Bug 10325230 which can cause a hang when user threads access java.lang.Process input streams while Resource Manager is active.


IncidentINC3035477 ------ INC0205114


DB: G2CPRD

Issue: Order Import program running long.


REQUEST_ID - 211528494

INST_ID - 1

SID - 3809

SERIAL# - 65261


Top SQLs are given below.



SQL_ID EVENT CURROBJNAME COUNT(*)

------------- -------------- ------------- --------

5rvh7z9yrwmmp OJVM: Generic 7956

5rvh7z9yrwmmp 1


SQL_TEXT: BEGIN xxg2c_auto_res_term_pkg.res_terminate(:errbuf,:rc,:A0,:A1); END;


SQL_ID: 5rvh7z9yrwmmp is the top SQL and currently hanged with wait-event - OJVM: Generic and is not a performance issue.

This wait-event is usally associated with the resource manager and caused due to some internal polling mechanism that has gone wrong causing a hang.


Whenever I have seen this wait-event in past (quite rare), a simple restart has fixed the issue.

If it resurfaces again and again, then maybe we are hitting a bug and Oracle should be involved.



Thanks & Regards,

Suraj



*****************************************************************************


alter session set  optimizer_features_enable = '12.1.0.2';




alter session set  optimizer_features_enable = '19.1.0';




ALTER SESSION SET "_optimizer_cbqt_or_expansion"= off;








SELECT /*+ OPTIMIZER_FEATURES_ENABLE('19.1.0') */ ATTRIB.OA_ATTRIB_ID

             FROM APPS.XXOA_ORDER_ATTRIB_WIPS ATTRIB

            WHERE     (ATTRIB.LINE_ID = :B3 OR ATTRIB.PARENT_LINE_ID = :B3)

                  AND ATTRIB.VERSION_ID = :B2

13/2/2020 (for excel ctrl + a and ctrl + insert / shift + insert) ============ PRB0068823 (INC2913704 josh) (INC3833475/ VVV imp INC0674838--- INC4449072 ---- prem/suraj G2CPRD) --------- INC6017536 --- Pdb SELECT * FROM table(DBMS_XPLAN.DISPLAY_AWR(sql_id=>'2k8z7fpqjbvdp',format => 'ADVANCED',plan_hash_value=>1619395103)); variable x varchar2(100); exec :x:=dbms_sqldiag.create_sql_patch(sql_id=>'2k8z7fpqjbvdp', hint_text=>'OPT_PARAM(''_optimizer_adaptive_plans'' ''FALSE'') optimizer_features_enable(''12.1.0.2'')', name=> 'SQL_Patch_adp_pln_false_ofe12102'); To check parameter was set on/OFF: ==================== SELECT a.ksppinm Param , b.ksppstvl SessionVal , c.ksppstvl InstanceVal, a.ksppdesc Descr FROM x$ksppi a , x$ksppcv b , x$ksppsv c WHERE a.indx = b.indx AND a.indx = c.indx AND a.ksppinm ='_optimizer_cbqt_or_expansion' ORDER BY 1; PARAM -------------------------------------------------------------------------------- SESSIONVAL -------------------------------------------------------------------------------- INSTANCEVAL -------------------------------------------------------------------------------- DESCR -------------------------------------------------------------------------------- _optimizer_cbqt_or_expansion OFF OFF enables cost based OR expansion MAKANCHA-3D0CB BOX USERNAME OS_USER PROGRAM ------------------------------ -------------------- -------------------- ------------------------------ PARTNERS\MAKANCHA-3D0CB PERF11I makancha Toad.exe Oracle SR Track : SR 3-30219096131 : Program taking more time in TS3CSF after 19 C upgrade. ********************************************************* OPT parameters OPT_PARAM('_b_tree_bitmap_plans' 'false') OPT_PARAM('_fast_full_scan_enabled' 'false') OPT_PARAM('_bloom_filter_enabled' 'false') OPT_PARAM('_optimizer_cbqt_or_expansion' 'off') OPT_PARAM('_optimizer_aggr_groupby_elim' 'false') OPT_PARAM('_optimizer_reduce_groupby_key' 'false') ***************************************************************** Run this when we dont see plan for xplan_display_awr/Cursor : ==================================================== SQL> set linesize 250 pagesize 0 trims on tab off long 1000000 SQL> column report format a220 SQL> SQL> select 2 DBMS_SQL_MONITOR.REPORT_SQL_MONITOR 3 (sql_id=>'bu6thnpcmmvsp',report_level=>'ALL') report 4 from dual; OPT_PARAM('_b_tree_bitmap_plans' 'false') OPT_PARAM('_optimizer_unnest_scalar_sq' 'false') OPT_PARAM('_px_adaptive_dist_method' 'off') OPT_PARAM('_optimizer_strans_adaptive_pruning' 'false') OPT_PARAM('_optimizer_cbqt_or_expansion' 'off') OPT_PARAM('_optimizer_aggr_groupby_elim' 'false') OPT_PARAM('_optimizer_reduce_groupby_key' 'false') OPT_PARAM('_optimizer_nlj_hj_adaptive_join' 'false') OPT_PARAM('_fix_control' '7452863:0') To monitor sql that is Running : ================================ select sql_id,Plan_hash_value,Rows_processed,buffer_gets,Disk_reads,EXECUTIONS from gv$sqlarea where sql_id='bu6thnpcmmvsp' SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME, SQL_ID, PLAN_HASH_VALUE, SUM (EXECUTIONS) EXECUTIONS, ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC, ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1) PIO_PER_EXEC, ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1) LIO_PER_EXEC, ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1) ROWS_PER_EXEC, ROUND ( (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1)) / GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1), 1), 1) lio_per_row, ROUND ( (SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'ms/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000) / GREATEST (SUM (EXECUTIONS), 1), 2) || 'sec/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000 / 60) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'min' TIME_PER_EXEC, MAX (sql_profile) sqlprofile FROM GV$SQL WHERE SQL_ID = '&sql_id' GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME) ORDER BY 1 DESC; Test case : 5 : ============== alter session set "_fix_control"='30998035:1','30972817:1','30222669:1','29867728:1','7452863:1'; alter session set "_optimizer_adaptive_cursor_sharing" = FALSE alter session set "_optimizer_extended_cursor_sharing_rel" = NONE alter session set "_optimizer_use_feedback" = FALSE To test Run for simple view merge is set to false : TS3CSF : Test case 1 : alter session set "_simple_view_merging" = false; alter session set "_complex_view_merging" = false; alter session set "_optimizer_use_feedback" = false alter session set "_optimizer_use_feedback" = false alter session set optimizer_features_enable = '12.1.0.2'; ************ This is basically to address 19c performance issue where most of the SQL's goes for Nested loop rather than hash join. alter session set "_fix_control"='26527656:0'; /*+ opt_param('optimizer_adaptive_plans','false') optimizer_features_enable('12.1.0.2') OPT_PARAM('_px_adaptive_dist_method','off') OPT_PARAM('_optimizer_use_feedback','false') */ /*+ NO_QUERY_TRANSFORMATION */ /*+ no_parallel */ /*+ opt_param('optimizer_adaptive_plans','false') optimizer_features_enable('12.1.0.2') OPT_PARAM('_px_adaptive_dist_method','off') OPT_PARAM('_optimizer_use_feedback','false') */ OPT_PARAM('_optimizer_use_feedback' 'false') OPT_PARAM('_px_adaptive_dist_method' 'off') OPT_PARAM('_optimizer_dsdir_usage_control' 0) OPT_PARAM('_optimizer_adaptive_plans' 'false') OPT_PARAM('_optimizer_strans_adaptive_pruning' 'false') OPT_PARAM('_optimizer_gather_feedback' 'false') alter session set "_fix_control"='26527656:0'; ************************ To check PX realted col PARAMETER for a40 col "DEFAULT_VALUE" for a20 col "SESSION_VALUE" for a20 col "INSTANCE_VALUE" for a20 col IS_SESSION_MODIFIABLE for a20 col IS_SYSTEM_MODIFIABLE for a20 SELECT a.ksppinm "PARAMETER", b.KSPPSTDF "DEFAULT_VALUE", b.ksppstvl "SESSION_VALUE", c.ksppstvl "INSTANCE_VALUE", decode(bitand(a.ksppiflg/256,1),1,'TRUE','FALSE') "IS_SESSION_MODIFIABLE", decode(bitand(a.ksppiflg/65536,3),1,'IMMEDIATE',2,'DEFERRED',3,'IMMEDIATE','FALSE') "IS_SYSTEM_MODIFIABLE" FROM x$ksppi a, x$ksppcv b, x$ksppsv c WHERE a.indx = b.indx AND a.indx = c.indx AND a.ksppinm LIKE '/_in_memory_cdt' escape '/' ; from Madan Kumar Kancharla (Cisco) to everyone: 8:34 PM TS3CSF PARAMETER DEFAULT_VALUE ---------------------------------------- -------------------- SESSION_VALUE INSTANCE_VALUE IS_SESSION_MODIFIABL -------------------- -------------------- -------------------- IS_SYSTEM_MODIFIABLE -------------------- _px_adaptive_dist_method TRUE CHOOSE CHOOSE TRUE IMMEDIATE alter session set "_fix_control"='13831671:0'; alter session set "_fix_control"='12555499:0'; alter session set "_fix_control"='26527656:0'; SELECT /*+ OPT_PARAM('_fix_control' '6377505:OFF 6006300:OFF') */ * FROM ...; SELECT /*+ OPT_PARAM('_fix_control' '6377505:OFF') */ * FROM ...; ALTER SESSION SET "_fix_control"='6377505:OFF','6006300:OFF'; ALTER SESSION SET "_fix_control"='6377505:OFF'; ALTER SESSION SET "_fix_control"='6377505:0'; -- On ALTER SESSION SET "_fix_control"='6377505:ON'; ALTER SESSION SET "_fix_control"='6377505:1'; select * from dba_sql_profiles order by created desc --- to check when sql profile depoyed alter session set optimizer_features_enable = '12.1.0.2'; ********** OPTIMIZER_FEATURES_ENABLE('19.1.0') SELECT /*+ opt_param('_optimizer_cbqt_or_expansion','off') optimizer_features_enable('12.1.0.2')*/ select /*+ opt_param('_optimizer_cbqt_or_expansion','off') optimizer_features_enable('12.1.0.2')*/ OEOLA.line_id, OEOLA.inventory_item_id, OEOLA.org_id, OEOLA.ship_from_org_id, OEOLA.order_quantity_uom, OEOLA.ordered_quantity, OEOLA.schedule_ship_date, OEOLA.booked_flag from APPS.OE_ORDER_LINES_ALL OEOLA ,APPS.wf_item_activity_statuses WAS ,APPS.wf_process_activities WPA where OEOLA.ORDERED_QUANTITY <> 0 and OEOLA.ATO_LINE_ID = OEOLA.LINE_ID and OEOLA.OPEN_FLAG = 'Y' and OEOLA.schedule_ship_date is not null and OEOLA.item_type_code in ( 'MODEL' , 'CLASS' ) and OEOLA.SHIP_FROM_ORG_ID = :organization_id and WAS.ACTIVITY_STATUS IN ('ACTIVE', 'NOTIFIED') and WAS.ITEM_TYPE = 'OEOL' and to_number(REGEXP_REPLACE(WAS.ITEM_KEY,'[[:alpha:]]|[[:punct:]]|[[:space:]]|[[:cntrl:]]','',1,0,'i')) = OEOLA.LINE_ID and REGEXP_INSTR(WAS.ITEM_KEY,'[[:alpha:]]|[[:punct:]]|[[:space:]]|[[:cntrl:]]',1,1,0,'i') = 0 and WAS.PROCESS_ACTIVITY = WPA.INSTANCE_ID and WPA.ACTIVITY_ITEM_TYPE = WAS.ITEM_TYPE and ( WPA.ACTIVITY_NAME = 'CREATE_CONFIG_ITEM_ELIGIBLE' OR ( WPA.ACTIVITY_NAME = 'BOOK_WAIT_FOR_H' AND OEOLA.SCHEDULE_STATUS_CODE = 'SCHEDULED' and not exists (select 'X' from APPS.OE_ORDER_LINES_ALL OEOLD where OEOLD.ato_line_id = OEOLA.ato_line_id and OEOLD.item_type_code = 'CONFIG' and rownum =1 ))) http://www.bigdatalyn.com/category/#Oracle /*+opt_param('_optimizer_skip_scan_enabled','off')*/ /*+ materialize */ /*+ gather_plan_statistics */ alter session set container=G2CPRD; alter session set "_optimizer_use_feedback" = false ********** alter session set "_simple_view_merging" = false; You can also hint the inner query block statement with /*+ NO_MERGE */. ************************************* use above if you want to format the date alter session set nls_Date_format='DD-MON-YYYY HH24:MI:SS'; To get SQLT report : ==================== Set trim on Set pages 0 Set linesize 32767 Set long 1000000 Set longchunksize 1000000 spool sqlmon_active_9j4w4qhvxpsy8_cg1prd5_83886080_27feb1215.html select dbms_sqltune.report_sql_monitor(sql_id=>'9j4w4qhvxpsy8', sql_exec_id=>344444,type=>'active', report_level=>'all') from dual; spool OFF ************** To get SQL monitor Report : =========================== select round((m.last_refresh_time - m.sql_exec_start)*24*60*60,2) run_time,m.sql_exec_start,m.first_refresh_time,m.last_refresh_time,m.sql_plan_hash_value,m.sql_exec_id,m.* from gv$sql_monitor m where sql_id='2hd217yv7whaj' order by status; ************************** ********** Dynamic sampling : –Session level. ALTER SESSION SET OPTIMIZER_DYNAMIC_SAMPLING=11; — Statement level SELECT /*+ dynamic_sampling(emp 11) */ empno, ename, job, sal FROM emp WHERE deptno = 30; ******** Cardinality feedback was introduced in Oracle Database 11g Release 2 and was renamed Statistics Feedback in Oracle Database 12c. The purpose of this feature is to automatically improve plans for queries that are executed repeatedly, for which the optimizer does not estimate cardinalities in the plan properly. The optimizer may misestimate cardinalities for a variety of reasons, such as missing or inaccurate statistics, or complex predicates. Whatever the reason for the misestimate, statistics feedback may be able to help. During the first execution of a SQL statement, an execution plan is generated as usual. During optimization, certain types of estimates that are known to be of low quality (for example, estimates for tables which lack statistics or tables with complex predicates) are noted, and monitoring is enabled for the cursor that is produced. If statistics feedback monitoring is enabled for a cursor, then at the end of execution, some of the statistics estimates in the plan are compared to the actual statistics seen during execution. If some of these estimates are found to differ significantly from the actual statistics, the correct estimates are stored for later use. The next time the query is executed, it will be optimized again, and this time the optimizer uses the corrected estimates in place of its usual estimates. The improved estimates used by cardinality feedback are not persisted. For this reason, it’s always preferable to use other techniques to get cardinality estimates right the first time every time, e.g. extended statistics, dynamic sampling, or SQL profiles. But for cases where these techniques do not apply, cardinality feedback can provide some relief. Query to check How 5 table was analyzed : ========================================== SELECT DT.OWNER, DT.TABLE_NAME, ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) PERCENTAGE FROM dba_tables dt, ALL_TAB_MODIFICATIONS atm WHERE DT.OWNER = ATM.TABLE_OWNER AND DT.TABLE_NAME = ATM.TABLE_NAME AND NUM_ROWS > 0 -- AND ROUND ( (DELETES + UPDATES + INSERTS) / NUM_ROWS * 100) >= 10 AND OWNER NOT IN ('SYS','SYSTEM','DBSNMP','OSMMON','PERFSTAT') AND dt.table_name like '%OE_ORDER_LINES_ALL%' ORDER BY 3 desc; De-Fragmentation ++++++++++++++++++++++++ *There are many methods. Option 1: Shrink command alter table enable row movement; /* Using the enable row movement clause can reduce the clustering_factor for a primary access index, causing excessive I/O. Oracle introduced the sorted gash cluster as a way to keep an index in-order with the table rows, a technique that greatly reduces I/O for common queries. Beware that using "enable row movement" can cause Oracle to move rows to discontinuous data blocks, causing a performance problem. Remember, the physical placement of rows on data blocks can still make a huge difference in query performance. */ alter table shrink space compact; alter table shrink space cascade; http://www.dba-oracle.com/t_enable_row_movement.htm Option 2: Table move Alter table move - The alter table xxx move command moves rows down into un-used space and adjusts the HWM but does not adjust the segments extents, and the table size remains the same. The alter table move syntax also preserves the index and constraint definitions. ALTER TABLE <table_name> MOVE; Option 3: EXPORT / IMPORT ** EXPORT ** DROP ALL RESPECTIVE OBJECTS ** IMPORT FROM EXPORT BACKUP Option 4: EXPORT / IMPORT WITH TABLE_EXISTS_ACTION=REPLACE ** EXPORT ** IMPORT USING TABLE_EXISTS_ACTION=REPLACE Query to get SQL Monitor Report : ================================= Set trim on Set pages 0 Set linesize 32767 Set long 1000000 Set longchunksize 1000000 spool sqlmon_active_b93d7617bt304_cg1prd5_83886080_17jun1404.html select dbms_sqltune.report_sql_monitor(sql_id=>'b93d7617bt304', type=>'active', report_level=>'all',sql_exec_id=>83886102) from dual; spool OFF to connect to CDB Database : ============================ c_perfusr zg2cprd#123# /*+ opt_param('_optimizer_mjc_enabled','false') opt_param('_optimizer_cartesian_enabled','false')*/ *********** to avoid merge join. /*+ opt_param('_optimizer_use_feedback' 'false') */ ******* ***** For upgrade 19 C issue learnings: alter session set optimizer_features_enable = '12.1.0.2'; Original query see o/p -=-- 3sec alter session set optimizer_features_enable = '19.1.0'; Original query see o/p ---- taking ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off; ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off; alter session set "_optimizer_mjc_enabled"=false; alter session set "_optimizer_cartesian_enabled"=false; alter session set "_optimizer_use_feedback"=false; ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off; anshukum@cisco.com / c1sc0P3rf ==== oracle cred INC7161849/INC7269527 ****** cg1 merge query ********** fts and read by other session and remove to_char function To drop the SQL profile : ++++++++++++++++++++++++ BEGIN DBMS_SQLTUNE.DROP_SQL_PROFILE ( name => 'PROFILE_gvpnmykf1ngr6' ); END; Manage SQL Profile in Oracle Database SQL Profile is used by Optimizer for use more efficient execution plan for the SQL Query to make in accepted State. It is found in DBA_SQL_PROFILES view. It used to choose better plan by optimizer if the SQL profile plan is having low cost then optimizer use it. Check the SQL Profile in the Database. COLUMN category FORMAT a10 COLUMN sql_text FORMAT a20 SELECT NAME,type, SQL_TEXT, CATEGORY, STATUS FROM DBA_SQL_PROFILES; Check the SQL Profile internal hint information SELECT a.name ,b.comp_data FROM dba_sql_profiles a ,dbmshsxp_sql_profile_attr b WHERE a.name = b.profile_name; Create the SQL Profiles Two ways: 1. Creating the SQL Profiles while running the manual SQL tuning task For manually creating with SQL Tuning task follows the link: SQL Tuning Advisory 2. Automatic SQL Tuning job runs on a daily basis (in Oracle Database 11g or higher). Check SQL profiles that have automatically been created having the value “AUTO” in the TYPE column of the DBA_SQL_PROFILES views --Check select name, type, status, sql_text from dba_sql_profiles; -- Enable exec DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER( parameter => 'ACCEPT_SQL_PROFILES', value => 'TRUE'); -- Disable DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER( parameter => 'ACCEPT_SQL_PROFILES', value => 'FALSE'); Disable the SQL Profiles BEGIN DBMS_SQLTUNE.ALTER_SQL_PROFILE( name => 'SYS_SQLPROF_789tfag56hjli0004', attribute_name => 'STATUS', value => 'DISABLED'); END; / Drop the SQL Profile exec dbms_sqltune.drop_sql_profile('SYS_SQLPROF_9824ryfg6f7d78653'); Drop all profiles in a database, using PL/SQL block: declare cursor c1 is select name from dba_sql_profiles; begin for r1 in c1 loop dbms_sqltune.drop_sql_profile(r1.name); end loop; end; /Manage SQL Profile in Oracle Database SQL Profile is used by Optimizer for use more efficient execution plan for the SQL Query to make in accepted State. It is found in DBA_SQL_PROFILES view. It used to choose better plan by optimizer if the SQL profile plan is having low cost then optimizer use it. Check the SQL Profile in the Database. COLUMN category FORMAT a10 COLUMN sql_text FORMAT a20 SELECT NAME,type, SQL_TEXT, CATEGORY, STATUS FROM DBA_SQL_PROFILES; Check the SQL Profile internal hint information SELECT a.name ,b.comp_data FROM dba_sql_profiles a ,dbmshsxp_sql_profile_attr b WHERE a.name = b.profile_name; Create the SQL Profiles Two ways: 1. Creating the SQL Profiles while running the manual SQL tuning task For manually creating with SQL Tuning task follows the link: SQL Tuning Advisory 2. Automatic SQL Tuning job runs on a daily basis (in Oracle Database 11g or higher). Check SQL profiles that have automatically been created having the value “AUTO” in the TYPE column of the DBA_SQL_PROFILES views --Check select name, type, status, sql_text from dba_sql_profiles; -- Enable exec DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER( parameter => 'ACCEPT_SQL_PROFILES', value => 'TRUE'); -- Disable DBMS_AUTO_SQLTUNE.SET_AUTO_TUNING_TASK_PARAMETER( parameter => 'ACCEPT_SQL_PROFILES', value => 'FALSE'); Disable the SQL Profiles BEGIN DBMS_SQLTUNE.ALTER_SQL_PROFILE( name => 'SYS_SQLPROF_789tfag56hjli0004', attribute_name => 'STATUS', value => 'DISABLED'); END; / Drop the SQL Profile exec dbms_sqltune.drop_sql_profile('SYS_SQLPROF_9824ryfg6f7d78653'); Drop all profiles in a database, using PL/SQL block: declare cursor c1 is select name from dba_sql_profiles; begin for r1 in c1 loop dbms_sqltune.drop_sql_profile(r1.name); end loop; end; / *********** Hi All, I have listed below a cool technique and effective mechanism to reduce the LOG FILE SYNC waits in 19c – Using this workaround helped and we were able to reduce LFS waits by more than 80% … Recently while looking into a system (was running on 19.3.0.0.0 standalone) where ‘log file sync’ was bugging the database, and after we tried all other possible solutions, we thought to increase the priority of the LGWR background process to see if that helps. Increasing the LGWR priority is putting the LGWR process in the Round-Robin (SCHED_RR) class. You can increase process’s priority both using OS (renice, nice commands) or Database methods, but this post is about setting the priority using ‘_high_priority_process’ an undocumented/hidden parameter that prioritizes your database managed processes. I am using Oracle 19.3 for the test where the LGWR is not by default comes with any priority in the DB, starting from 21.3.0.0.0 LGWR process is part of _high_priority_processes group along with VKTM & LMS* processes. Note: This being a hidden/undocumented parameter I advise to consult with Oracle support before going and changing the parameter value. Try other possible ways to reduce log file sync, before jumping into this crude method of prioritizing LGWR over others. [oracle@oracleontario ~]$ !sql sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Sun Apr 10 03:36:06 2022 Version 19.3.0.0.0 Copyright (c) 1982, 2019, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.3.0.0.0 SQL> @hidden Enter value for param: high_prio old 5: and a.ksppinm like '%&param%' new 5: and a.ksppinm like '%priority_processes%' Parameter Session Value Instance Value descr --------------------------------------------- ------------------------- ------------------------- ------------------------------------------------------------ _highest_priority_processes VKTM VKTM Highest Priority Process Name Mask _high_priority_processes LMS*|VKTM LMS*|VKTM High Priority Process Name Mask And by default in Oracle version 19.3.0.0 the parameter is set to prioritize VKTM (Virtual keeper of time) and LMS (Lock Manager, a RAC process). Let me check VKTM’s current priority class, and it is set to RR class (SCHED_RR scheduling class) for the process as its defined via _high_priority_processes parameter. [oracle@oracleontario ~]$ ps -eo pid,class,pri,nice,time,args |grep vktm 23871 RR 41 - 00:00:53 ora_vktm_dixitdb About the LGWR process, and it is set to TS (SCHED_OTHER) class and it has no priority class attached to it. [oracle@oracleontario ~]$ ps -eo pid,class,pri,nice,time,args |grep ora_lg* 23990 TS 19 0 00:00:07 ora_lgwr_dixitdb Let’s change the priority and reboot the database to persistent the change! SQL> alter system set "_high_priority_processes"='LMS*|VKTM|LGWR' scope=spfile; System altered. SQL> shut immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 1593831936 bytes Fixed Size 8897024 bytes Variable Size 1107296256 bytes Database Buffers 469762048 bytes Redo Buffers 7876608 bytes Database mounted. Database opened. SQL> @hidden Enter value for param: high_priority_processes old 5: and a.ksppinm like '%&param%' new 5: and a.ksppinm like '%high_priority_processes%' Parameter Session Value Instance Value descr --------------------------------------------- ------------------------- ------------------------- ------------------------------------------------------------ _high_priority_processes LMS*|VKTM|LGWR LMS*|VKTM|LGWR High Priority Process Name Mask At the same time I can see the same was logged into the Alert log file. 2022-04-10T03:54:31.488732-04:00 LGWR started with pid=8, OS id=26058 at elevated (RT) priority So, we have reniced the priority of LGWR on the system, I mean the higher value of priority actually makes the process lower priority; it means the process demands fewer system resources (and therefore is a “nicer” process). Now lets check the scheduling class of the process at the OS, it should be now changed to RR from TS. SQL> !ps -eo pid,class,pri,nice,time,args |grep ora_lm* 26058 RR 41 - 00:00:00 ora_lgwr_dixitdb Let me check at the OS Level what has changed now. [oracle@oracleontario 26058]$ pwd /proc/26058 [oracle@oracleontario 26058]$ more sched ora_lgwr_dixitd (26058, #threads: 1) ------------------------------------------------------------------- se.exec_start : 26820431.663015 se.vruntime : -2.963799 se.sum_exec_runtime : 1858.211503 se.nr_migrations : 0 nr_switches : 4038 nr_voluntary_switches : 4023 nr_involuntary_switches : 15 se.load.weight : 1024 policy : 2 -----> Policy, the 0-99 are real-time priorities prio : 98 clock-delta : 59 mm->numa_scan_seq : 0 numa_migrations, 0 numa_faults_memory, 0, 0, 1, 0, -1 numa_faults_memory, 1, 0, 0, 0, -1 -- output from top utility top - 05:09:14 up 7:32, 3 users, load average: 0.14, 0.10, 0.11 Tasks: 2 total, 0 running, 2 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st GiB Mem : 4.3 total, 0.0 free, 1.1 used, 3.1 buff/cache GiB Swap: 3.9 total, 3.9 free, 0.0 used. 2.1 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 26027 oracle -2 0 2016104 20096 17064 S 1.7 0.4 1:28.22 ora_vktm_dixitdb ---> Look at the PR (priority) column with value -2 (higher pri) 26058 oracle -2 0 2017136 30360 26768 S 0.0 0.7 0:01.86 ora_lgwr_dixitdb ---> Look at the PR (priority) column with value -2 (higher pri) So, when nothing was working for us, this workaround helped and we were able to reduce LFS waits by more than 80% … *************** IA0006051/INC7297766 M-Job Partner channels Revenue posting job on DB:PDBPROD perf analysisIA0006051/INC7297766 M-Job Partner channels Revenue posting job on DB:PDBPROD perf analysis Query to check parallel degrade : SELECT s.sql_id, s.osuser, (req_degree - degree) parallel_degradation, ps.* FROM gv$session s, gv$PX_SESSION ps WHERE 1=1 --and osuser IN ('nboobala', 'sunaqvi', 'ramknair') AND status = 'ACTIVE' AND s.saddr = ps.saddr ORDER BY qcsid; https://dba.cisco.com/dba-portal/tools/session-details/ ****** To check session details from db portal Incident INC7329407 is assigned to group DBA-Oracle Incident INC7329407 has been assigned to group DBA-Oracle Caller: Sriganesh Palani (sripalan) Service Offering: Oracle Database Summary: Unable to access SVSTST instance Severity: 3 - Low Priority: 5 - Standard *********** Query to check Configurations od Database select distinct name,value from gv$parameter where name like 'parallel_max_servers' union select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'sga_target' union select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'pga_aggregate_target' union select distinct name,value from gv$parameter where name like 'db_file_multiblock_read_count' union select distinct name,value from gv$parameter where name like 'undo_retention' union select distinct name,value from gv$parameter where name = 'parallel_threads_per_cpu' union select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'db_cache_size' union select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'sga_max_size' union select distinct name,to_char(round(value/1024/1024/1024,2))||' GB' from gv$parameter where name like 'shared_pool_size' ************************ Hi Team, Oracle Team suggested to drop and create the SQL Profile. Please work on the action item shared by Oracle team in DV1CG1. To implement the solution, please execute the following steps: 0. Please implement this action plan in a TEST instance FIRST. 1. Use the script coe_xfr_sql_profile.sql provided in Note 215187.1 :SQLTXPLAIN.SQL - Enhanced Explain Plan and related diagnostic info for one SQL statement a. Uncompress sqlt.zip b. Look for coe_xfr_sql_profile.sql under /<directory where you unzipped sqlt.zip file>/utl/coe_xfr_sql_profile.sql NOTE: This script will generate another that contains the commands to create a manual custom SQL Profile out of a known plan from memory or AWR. REM EXECUTION REM 1. Navigate to directory where this script resides. REM 2. Start SQL*Plus connecting as SYSDBA. REM 3. Execute script coe_xfr_sql_profile.sql passing SQL_ID and REM PLAN_HASH_VALUE (parameters can be passed inline or until requested) REM REM EXAMPLE REM # cd sqlt/utl REM # sqlplus system REM SQL> start coe_xfr_sql_profile.sql [SQL_ID] [PLAN_HASH_VALUE]; REM SQL> start coe_xfr_sql_profile.sql 5pb8pd95rynrs 1464560987; c. The script will require the sql id and the hash value for the query with the problem. These values can be obtained from the trace file. Example: sqlid='1wmm1trqkzhzq' hv=3979332550 2. This script will generate a profile for that statement 3. Drop the sql profile Example: BEGIN DBMS_SQLTUNE.DROP_SQL_PROFILE(name => '<my sql profile name>'); END; / 4. Execute the coe_xfr_sql_profile.sql script generated to recreate the sql profile Regards, Sreedevi **************************************** IncidentINC7263796 :::::: XXSSOT.SHR_EMP_ASSIGNMENTS_MV Schema : XXSSOT DB : ESALESPD INC7190068 *** Cg1 *** suraj Re: INC7133477 - GCDPRD - Materialized view is failing since 22nd Dec 2021 : INC7173939 :::::: https://dba.cisco.com/dba-portal/tools/dbts https://dba.cisco.com/dbstatus/login.do https://dba.cisco.com/dba-portal/dashboard **** Dash board http://www.nazmulhuda.info/fix-unusable-index ==== to make index rebuild or unusable. ***** For upgrade 19 C issue learnings: alter session set optimizer_features_enable = '12.1.0.2'; Original query see o/p -=-- 3sec alter session set optimizer_features_enable = '19.1.0'; Original query see o/p ---- taking ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off;ALTER SESSION SET "_optimizer_cbqt_or_expansion"=off; https://dba.cisco.com/dba-portal/tools/session-details/CSFPRD Approch one : For sql id art0f01ftyq9b, we have seen sql performance has degraded after the upgrade. So, we have tested the query by setting the optimizer_features_enable = '12.1.0.2' and the query is getting complete within few secs as before. Let's apply a sql patch as below : SQL> connect / as sysdba SQL> variable x varchar2(100); SQL> exec :x:=dbms_sqldiag.create_sql_patch(sql_id=>'art0f01ftyq9b', hint_text=>'optimizer_features_enable(''12.1.0.2'')', name=> 'SQL_Patch_12.1.0.2_art0f01ftyq9b'); to drop sql patch : =================== BEGIN DBMS_SQLDIAG.drop_sql_patch(name => 'SQL_Patch_12.1.0.2_4hm4452dujza2'); END; / How to Create a SQL Patch to add Hints to Application SQL Statements (Doc ID 1931944.1) /*+ OPTIMIZER_FEATURES_ENABLE('12.1.0.2') DB_VERSION('12.1.0.2') */ ***** INC7190068 **** vimp *** CG! INC7185721_analysis === enq: TX - row lock contention High Enq: TM - Contention Wait Events When Using Insert APPEND (Doc ID 2247733.1) Resolving Issues Where Lock Contention for 'enq: TM - contention' Wait Event (TM Enqueue Contention) Occurs During ANALYZE INDEX VALIDATE STRUCTURE (Doc ID 1476083.1) Reducing Number of Waits: There is no actual solution for this issue other than to run the ANALYZE INDEX command during a maintenance window or quiet time; "ONLINE" option for the ANALYZE INDEX VALIDATE STRUCTURE command can be used as workaround. Or, You will simply need to avoid the contention by scheduling the command when there is no contention likely. SYMPTOMS High waits on "enq: TM - contention" when using INSERT APPEND or INSERT APPEND_VALUES: Top 10 Foreground Events by Total Wait Time Event Waits Total Wait Time (sec) Wait Avg(ms) % DB time Wait Class DB CPU 4479.1 62.4 enq: TM - contention 118 1693.5 14351.89 23.6 Application CHANGES CAUSE Insert append needs to require a lock at object level. So the first session holds TM lock in X mode to lock the object. The rest of sessions must wait until the lock is released. SOLUTION Avoid using insert append in busy tables Or Rebalance your workload to decrease the concurrency https://dba.cisco.com/dba-portal/tools/session-details =========== for trace Interesting GG replicat perf issue I have updated the incident ticket with the STF >>> INC7182999. Kindly go through it as its a good learning exercise on how to fix replicat issues and improve replicat process performance Reference ORACLE MOS Note : Main Note - Oracle GoldenGate - Lag, Performance, Slow and Hung Processes (Doc ID 1304557.1) For High Undo usage for instance level :(Suraj) ========================================= Kindly use below query to find top SQLs with high undo usage for each instance while doing your performance analysis for your assigned DBs. SELECT b.sql_id, a.sql_hash_value, a.osuser, a.username, MAX (mb_used_ublk), a.inst_id, a.program, a.module FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b WHERE a.snap_date_time > SYSDATE - :no_of_days AND sql_hash_value != 0 and a.sql_hash_value = b.sql_hash and a.inst_id= :inst_id GROUP BY b.sql_id, a.sql_hash_value, a.osuser, a.username, a.inst_id, a.program, a.module HAVING MAX (mb_used_ublk) > 500 ORDER BY 5 DESC ********************************************************************************************************************************** INC3035477 ***** OJVM case INC7133477 - GCDPRD - Materialized view is failing since 22nd Dec 2021 select flashback_on from gv$database ******** To check flashback is on or off ************* **************************************************************** STEPS TO TROUBLESHOOT INACTIVE SESSIONS IN THE ORACLE DATABASE **************************************************************** 1. Check the inactive session present in database -- Check inactive and active session count select status, count(1) from gv$session group by status; --Check username,programname inactive count select username, program, count(1) from gv$session where status='INACTIVE' and username = 'CPCTADM' group by username, program; --Find more details of inactive count select p.username "OSUSERNAME", p.terminal,p.program, s.username "DBUSERNAME",s.command,s.status, s.server,s.process,s.machine,s.port,s.terminal,s.program, s.sid,s.serial#,p.spid FROM gv$session s, gv$process p WHERE p.addr=s.paddr and s.status='INACTIVE' order by 1,4; 2. Inactive session is caused due to Dead Connection or IDLE Connection DEAD Connection is handle by SQLNET.ORA file by configuring parameter SQLNET.EXPIRE_TIME=minutes Open the SQLNET ORA file and set the parameter. it is client file so set it in client side. SQLNET.EXPIRE_TIME=60 (1 hour) IDLE Connection is set at USER PROFILES, define profile with IDLE_TIME limit so that INACTIVE SESSION killed after the time limit reached. -- Need to enable resource limit so it automatic terminate the session. alter system set resource_limit=true scope=both; --Check user which profile it uses SELECT USERNAME, USER_ID, PROFILE FROM DBA_USERS; --check profile setting for IDLE_TIME select profile, limit from DBA_PROFILES where resource_name = 'IDLE_TIME'; --Alter IDLE TIME to 30 minutes after it disconnect alter profile customers_profiles limit idle_time 30; Note: idle_time parameter will disconnect sessions after n minutes of inactivity. Note: We can also use Resource Manager to kill INACTIVE SESSION that are idle crossed the timelimit of MAX_IDLE_TIME limit the detailed steps for whcih are listed below. ************************************************************************* Steps to Configure Resource Manager to kill INACTIVE SESSIONS in Oracle ************************************************************************* 1. Create a pending area for resource plan. Exec dbms_resource_manager.create_pending_area(); 2. Create a plan for kill inactive session after crossed idle time. --Check the name already exists SELECT plan,status,comments FROM dba_rsrc_plans; --Create the plan Exec dbms_resource_manager.create_plan( plan => 'Kill_INACTIVE_PLAN', comment => 'kill inactive sessions'); 3. Create the consumer groups. Exec dbms_resource_manager.create_consumer_group( consumer_group => 'LONG_RUN',comment =>'Privileged Users'); Exec dbms_resource_manager.create_consumer_group( consumer_group => 'SHORT_RUN',comment => 'Under Privileged Users'); 4. Create directives for the plan in Resource manager you can define directives which is used by different setting for configure different user to different directives that will use different time limit as following examples. Exec dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan => 'LONG_RUN', comment => '15 minutes', max_idle_time => 900); Exec dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan => 'SHORT_RUN', comment => '5 minute idle time', max_idle_time => 300); EXEC dbms_resource_manager.create_plan_directive( plan => 'Kill_INACTIVE_PLAN', group_or_subplan => 'OTHER_RUN', comment => '1 Hour ideal time', max_idle_time => 3600); 5. Submit the plan in Resource Manager. Exec dbms_resource_manager.validate_pending_area(); Exec dbms_resource_manager.submit_pending_area(); 6. Consumer group switching begin dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'SYSTEM', consumer_group => 'LONG_RUN', grant_option => FALSE); dbms_resource_manager_privs.grant_switch_consumer_group(grantee_name => 'TEST', consumer_group => 'SHORT_RUN', grant_option => FALSE); end; / 7. Change database users default consumer groups: Assign user SYSTEM to the group LONG_RUN Assign user TEST to the group SHORT_RUN begin dbms_resource_manager.create_pending_area(); dbms_resource_manager.set_initial_consumer_group( user => 'SYSTEM', consumer_group => 'LONG_RUN'); dbms_resource_manager.set_initial_consumer_group( user => 'TEST', consumer_group => 'SHORT_RUN'); dbms_resource_manager.validate_pending_area(); dbms_resource_manager.submit_pending_area(); end; / 8. Change resource plan for database and make it active. alter system set resource_manager_plan='Kill_INACTIVE_PLAN'; 9. Check query start using the new resource plan SYSTEM user assigned to LONG_RUN and TEST user assigned to SHORT_RUN and the rest of the users with OTHER_RUN SELECT sid,serial#,username,resource_consumer_group FROM gv$session; ORACLE MOS NOTE: >>> Too Many SO_TIMEOUT And Inactive Database Sessions After Upgrading to WebLogic 12.2.1.4 (Doc ID 2814178.1) =========================== ************query to confirm the rows select s.plan_hash_value,s.sql_id ,s.executions_delta ,s.elapsed_time_delta ,s.rows_processed_delta ,rows_processed_total --,round(((s.elapsed_time_delta/1000000)/s.executions_delta),2) avg_elap_in_seconds ,s.cpu_time_delta ,n.begin_interval_time ,n.end_interval_time ,s.* from dba_hist_Sqlstat s,dba_hist_snapshot n where --s.instance_number=4 1=1 and s.snap_id=n.snap_id and s.instance_number=n.instance_number --and s.executions_delta>0 and n.begin_interval_time between to_timestamp('10-Feb-2022 16:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('11-Feb-2022 23:00:00','DD-MON-YYYY HH24:MI:SS') and s.sql_id='59ymgucb5hhyy' --and s.sql_id='frv6z0mjuckw9' order by s.snap_id; ***************************** select * from XXCPF_FND_CONC_REQ_ARCHIVE where concurrent_program_id=32781 and request_id in(123729691,123729683,122058441,122058432) order by actual_start_date desc; select * from xxcpf_pm_snapshot where prog_id=32781; select owner,object_name,status,object_type from dba_objects where object_name like 'PO_REQUISITION_LINES_ALL'; --------------- select * from XXCPF_FND_CONC_REQ_ARCHIVE where concurrent_program_id=32781 and request_id in(123729691,123729683,122058441,122058432) order by actual_start_date desc; select * from xxcpf_pm_snapshot where prog_id=32781; https://www.oradev.com/hints.jsp *********** for Hints ****Josh****** Temp Usage query The query used to gather the necessary set of information is listed below : select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig from DBA_HIST_ACTIVE_SESS_HISTORY where sample_time > sysdate-30 and TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) group by sql_id order by sql_id; This is a great feature of these ASH views. Now we can go back in time and find the queries that were using all the temp space and tune them. ++++++++++++++++++++++++++ Hi Madan, FOR CFNPRD ANALYSIS use this query to find top request id which run for longest time. and then try to find session details and top SQL id for that request SELECT fcr.request_id, fcr.concurrent_program_id prog_id, fcp.concurrent_program_name prog_name, fcp.application_id app_id, fcr.parent_request_id parent, DECODE (fcr.phase_code, 'C', 'Completed', 'I', 'Inactive', 'P', 'Pending', 'Running', 'Unknown') Phase, DECODE (fcr.status_code, 'D', 'Cancelled', 'U', 'Disabled', 'E', 'Error', 'M', 'No Manager', 'R', 'Normal', 'I', 'Normal', 'C', 'Normal', 'H', 'On Hold', 'W', 'Paused', 'B', 'Resuming', 'P', 'Scheduled', 'Q', 'Standby', 'S', 'Suspended', 'X', 'Terminated', 'T', 'Terminating', 'A', 'Waiting', 'Z', 'Waiting', 'G', 'Warning', 'Unknown') Status, fcr.Argument_text, fcr.requested_start_date, fcr.actuaL_start_date, fcr.actual_completion_date, ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24 * 60 * 60, 2) || 'secs/' || ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24 * 60, 2) || 'mins/' || ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24, 2) || 'hrs' Time,ROUND ( (fcr.actual_completion_date - fcr.actual_start_date) * 24, 2) hrs FROM apps.fnd_concurrent_requests fcr, apps.fnd_concurrent_programs fcp WHERE 1 = 1 AND fcr.concurrent_program_id = fcp.concurrent_program_id --AND (fcr.request_id = :req_id or fcr.parent_request_id=:req_id) AND fcr.concurrent_program_id = :prog_id ORDER BY hrs DESC after getting top SQL just see its execution History and compare the stats before and after update. based on that u need to provide observation. Aditya Thakur Yesterday, 10:54 PM if you are not getting any details in xxcpf_snapshot table then use select * from XXCPF_FND_CONC_REQ_ARCHIVE where request_id=123752626 to find session details and if no session details are there in this table also then u can mention as no details found. +++++++++++++++++++++++++++++++++++++++++ ***************** Main querys shared by suraj to check Temp/undo SQL from DATABASE Temp available space SELECT inst_id, tablespace_name, ROUND ( (free_blocks * 8) / 1024 / 1024, 2) FreeSpaceInGB, ROUND ( (used_blocks * 8) / 1024 / 1024, 2) UsedSpaceInGB, ROUND ( (total_blocks * 8) / 1024 / 1024, 2) TotalSpaceInGB FROM gv$sort_segment WHERE tablespace_name LIKE '%TEMP%' ORDER BY 1, 2; Top Temp SQLs SELECT /*+ parallel(8) */ sql_id, MAX (sql_plan_hash_value) plan_hash, MAX (TEMP_SPACE_ALLOCATED) / (1024 * 1024 * 1024) gig, MAX (program) program, MAX (module) module, (SELECT username FROM dba_users WHERE user_id = a.user_id) username FROM DBA_HIST_ACTIVE_SESS_HISTORY a WHERE TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) -- over 50 GB (change as per size of your instance temp space) AND sample_time > SYSDATE - 21 AND instance_number = :inst_id GROUP BY sql_id, a.user_id ORDER BY 3 DESC NULLS LAST; Top UNDO SQLs SELECT b.sql_id, MAX (a.sql_hash_value) sql_hash, MAX (a.osuser) osuser, MAX (a.username) username, MAX (mb_used_ublk), SUM (mb_used_ublk), MAX (a.inst_id) inst_id, MAX (a.program) program, MAX (a.module) module FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b WHERE a.snap_date_time > SYSDATE - :no_of_days AND sql_hash_value != 0 AND a.sql_hash_value = b.sql_hash AND a.inst_id = :inst_id GROUP BY b.sql_id HAVING MAX (mb_used_ublk) > 500 ORDER BY 5 DESC ********************* To send test page : rmo-perf@epage.cisco.com and https://mailer.cisco.com/ for getting notification of pager duity need to add id in https://naas.cisco.com/epage/calendar/rmo-perf To check bind peeks : ====================== select * from table(dbms_xplan.display_awr ('dwh6crb9kv06n', format => 'TYPICAL +PEEKED_BINDS')) To get Size of the DB : ======================= col "Database Size" format a20 col "Free space" format a20 col "Used space" format a20 select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size" , round(sum(used.bytes) / 1024 / 1024 / 1024 ) - round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space" , round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space" from (select bytes from v$datafile union all select bytes from v$tempfile union all select bytes from v$log) used , (select sum(bytes) as p from dba_free_space) free group by free.p / O/p: Database Size Used space Free space 66582 GB 57576 GB 9006 GB https://dba.cisco.com/dba-portal/tools/session-details ====== trace ################################### Quer's to check undo usage : select a.sid, a.serial#, a.username, b.used_urec used_undo_record, b.used_ublk used_undo_blocks from gv$session a, gv$transaction b where a.saddr=b.ses_addr ; Check the SQL TEXT using or generating undo segments select distinct(s.sql_id),s.sql_text from gv$sql s, gv$undostat u where u.maxqueryid=s.sql_id; OR select sql.sql_text, t.used_urec records, t.used_ublk blocks, (t.used_ublk*8192/1024) kb from v$transaction t, v$session s, v$sql sql where t.addr=s.taddr and s.sql_id = sql.sql_id; Finding what's consuming the most UNDO Very often DBA's see that one or more session seem to be hogging the UNDO tablespace. You need to find out what user and which SQL statement is eating up all the UNDO space. SQL> select s.sql_text from gv$sql s, gv$undostat u where u.maxqueryid=s.sql_id; You can also use following SQL to find out most undo used by a session for a currently executing transaction. SQL> select s.sid,s.username,t.used_urec,t.used_ublk from gv$session s, gv$transaction t where s.saddr = t.ses_addr order by t.used_ublk desc; To find out which session is currently using the most UNDO, SQL>select s.sid, t.name, s.value from gv$sesstat s, gv$statname t where s.statistic#=t.statistic# and t.name='undo change vector size' order by s.value desc; SQL> select sql.sql_text, t.used_urec records, t.used_ublk blocks, (t.used_ublk*8192/1024) kb from v$transaction t, v$session s, v$sql sql where t.addr=s.taddr and s.sql_id = sql.sql_id and s.username ='&USERNAME'; +++++++++++++++++++++++++ To check specific time timestamp for the query : SELECT /*+parallel(8)*/ sql_id, COUNT(*), event FROM gv$active_session_history WHERE sample_time BETWEEN TO_DATE('16-mar-2022 22:40:29', 'DD-Mon-YYYY HH24:MI:SS') AND TO_DATE('16-mar-2022 22:53:05', 'DD-Mon-YYYY HH24:MI:SS') AND upper(module) LIKE '%WINNERS_BATCH%' AND sql_id = '4cb3ufq8126jb' GROUP BY sql_id, event ORDER BY COUNT(1) DESC; ################################################# when we have Program name : ++++++++++++++++++++++++++ SELECT c.user_concurrent_program_name, a.concurrent_program_id, b.user_name, request_id, actual_start_date, actual_completion_date, SYSDATE, phase_code, status_code, request_id, ARGUMENT_TEXT FROM apps.fnd_concurrent_requests a, apps.fnd_user b, apps.fnd_concurrent_programs_tl c WHERE a.concurrent_program_id = c.concurrent_program_id AND c.user_concurrent_program_name ='CTS FIN - Generate India Domestic Documents' AND a.requested_by = b.user_id --and status_code = 'R' ORDER BY actual_start_date DESC SELECT DISTINCT module FROM xxcpf_pm_snapshot WHERE prog_id = 1261623 select sql_id,count(*) from xxcpf_pm_snapshot where module='e:XXCTS_SLM:cp:xxcts_plan/XXCTS_PLAN_C2S_PDL_DAT' group by sql_id order by 2 desc Temp Usage : IMP =========== select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig from DBA_HIST_ACTIVE_SESS_HISTORY where 1=1--TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) -- over 50 GB AND sample_time > sysdate-2 and insatcne_number = :instance_number group by sql_id order by 2 desc nulls last; select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig from DBA_HIST_ACTIVE_SESS_HISTORY where 1=1--TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) -- over 50 GB AND sample_time > sysdate-2 and insatcne_number = :instance_number group by sql_id order by 2 desc nulls last; instance_number* Suraj suggested query TO CHECK Temp usage : =========================================== SELECT b.sql_id, a.sql_hash_value, a.osuser, a.username, MAX (mb_used_ublk), a.inst_id, a.program, a.module FROM xxcpf_pm_rollsp a, xxcpf_pm_sqlarea b WHERE a.snap_date_time > SYSDATE - :no_of_days AND sql_hash_value != 0 and a.sql_hash_value = b.sql_hash and a.inst_id= :inst_id GROUP BY b.sql_id, a.sql_hash_value, a.osuser, a.username, a.inst_id, a.program, a.module HAVING MAX (mb_used_ublk) > 500 Sql Hanging or not : ++++++++++++++++++ select sess_io.inst_id, sess_io.sid, sesion.sql_id, sess_io.block_gets, sess_io.consistent_gets, sess_io.physical_reads, sess_io.block_changes, sess_io.consistent_changes from gv$sess_io sess_io, gv$session sesion where sesion.sid = sess_io.sid and sess_io.inst_id = sesion.inst_id and sesion.sql_id='&sql_id' and sesion.username is not null ;" select sess_io.inst_id, sess_io.sid, sess_io.block_gets, sess_io.consistent_gets, sess_io.physical_reads, sess_io.block_changes, sess_io.consistent_changes from gv$sess_io sess_io, gv$session sesion where sesion.sid = sess_io.sid and sess_io.inst_id = sesion.inst_id and sesion.username is not null ################################################### ********************************* Instance Tuning : select name,value from gv$parameter where name in ('shared_pool_size','log_buffer','db_block_size','db_cache_size','sga_max_size','sga_target','memory_target','memory_max_target') PGA : select pga_target_for_estimate,pga_target_factor,estd_extra_bytes_rw from gv$pga_target_advice; **************** VIMP select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id ---AND s.sid = 2129 ----AND s.inst_id = 4 AND s.sql_id = 'gp4k0b7s0wsth' ---AND substr(m.status,1,4) = 'EXEC' and m.sql_exec_id= 67108869 AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id select sql_exec_id from gv$sql_plan_monitor where sql_id = 'gp4k0b7s0wsth' order by output_rows desc PDB PLan change monitoring : PERF_PDBPROD_SQL_MONITORING --- Procedure and PERF_PDBPROD_PLAN_Change --- Table select distinct SQL_ID from xxcpf_pm_snapshot where SQL_ID IN(select SQL_ID from PERF_PDBPROD_PLAN_Change) and schema='PRE_ADMIN' select * from PERF_PDBPROD_PLAN_Change where SQL_ID='1j4gyk642sn4a' select * from PERF_PDBPROD_PLAN_Change select * from xxcpf_pm_snapshot ++++++++++++++ CREATE OR REPLACE PROCEDURE PERF11I.PERF_PDBPROD_SQL_MONITORING AS BEGIN INSERT INTO PERF_PDBPROD_PLAN_CHANGE (SQL_ID, TOTAL_VERSION, REASON, LOG_TIME) select sql_id,count(*) total_version,'' ||decode(max( UNBOUND_CURSOR),'Y', ' UNBOUND_CURSOR' ||'( '||SUM(DECODE( UNBOUND_CURSOR,'Y',1,0))||')' ) ||decode(max( SQL_TYPE_MISMATCH),'Y', ' SQL_TYPE_MISMATCH' ||'( '||SUM(DECODE( SQL_TYPE_MISMATCH,'Y',1,0))||')' ) ||decode(max( OPTIMIZER_MISMATCH),'Y', ' OPTIMIZER_MISMATCH' ||'( '||SUM(DECODE( OPTIMIZER_MISMATCH,'Y',1,0))||')') ||decode(max( OUTLINE_MISMATCH),'Y', ' OUTLINE_MISMATCH' ||'( '||SUM(DECODE( OUTLINE_MISMATCH,'Y',1,0))||')') ||decode(max( STATS_ROW_MISMATCH),'Y', ' STATS_ROW_MISMATCH' ||'( '||SUM(DECODE( STATS_ROW_MISMATCH,'Y',1,0))||')') ||decode(max( LITERAL_MISMATCH),'Y', ' LITERAL_MISMATCH' ||'( '||SUM(DECODE( LITERAL_MISMATCH,'Y',1,0))||')') -- ||decode(max( SEC_DEPTH_MISMATCH),'Y', ' SEC_DEPTH_MISMATCH' ||'( '||SUM(DECODE( SEC_DEPTH_MISMATCH,'Y',1,0))||'' ||decode(max( EXPLAIN_PLAN_CURSOR),'Y', ' EXPLAIN_PLAN_CURSOR' ||'( '||SUM(DECODE( EXPLAIN_PLAN_CURSOR,'Y',1,0))||')') ||decode(max( BUFFERED_DML_MISMATCH),'Y', ' BUFFERED_DML_MISMATCH' ||'( '||SUM(DECODE(BUFFERED_DML_MISMATCH,'Y',1,0))||')') ||decode(max( PDML_ENV_MISMATCH),'Y', ' PDML_ENV_MISMATCH' ||'( '||SUM(DECODE( PDML_ENV_MISMATCH,'Y',1,0))||')') ||decode(max( INST_DRTLD_MISMATCH),'Y', ' INST_DRTLD_MISMATCH' ||'( '||SUM(DECODE( INST_DRTLD_MISMATCH,'Y',1,0))||')') ||decode(max( SLAVE_QC_MISMATCH),'Y', ' SLAVE_QC_MISMATCH' ||'( '||SUM(DECODE( SLAVE_QC_MISMATCH,'Y',1,0))||')') ||decode(max( TYPECHECK_MISMATCH),'Y', ' TYPECHECK_MISMATCH' ||'( '||SUM(DECODE( TYPECHECK_MISMATCH,'Y',1,0))||')') ||decode(max( AUTH_CHECK_MISMATCH),'Y', ' AUTH_CHECK_MISMATCH' ||'( '||SUM(DECODE( AUTH_CHECK_MISMATCH,'Y',1,0))||')') ||decode(max( BIND_MISMATCH),'Y', ' BIND_MISMATCH' ||'( '||SUM(DECODE( BIND_MISMATCH,'Y',1,0))||')') ||decode(max( DESCRIBE_MISMATCH),'Y', ' DESCRIBE_MISMATCH' ||'( '||SUM(DECODE( DESCRIBE_MISMATCH,'Y',1,0))||')') ||decode(max( LANGUAGE_MISMATCH),'Y', ' LANGUAGE_MISMATCH' ||'( '||SUM(DECODE( LANGUAGE_MISMATCH,'Y',1,0))||')') ||decode(max( TRANSLATION_MISMATCH),'Y', ' TRANSLATION_MISMATCH' ||'( '||SUM(DECODE( TRANSLATION_MISMATCH,'Y',1,0))||')') --||decode(max( ROW_LEVEL_SEC_MISMATCH),'Y', ' ROW_LEVEL_SEC_MISMATCH' ||'( '||SUM(DECODE( ROW_LEVEL_SEC_MISMATCH,'Y',1,0))||'' ||decode(max( INSUFF_PRIVS),'Y', ' INSUFF_PRIVS' ||'( '||SUM(DECODE( INSUFF_PRIVS,'Y',1,0))||')') ||decode(max( INSUFF_PRIVS_REM),'Y', ' INSUFF_PRIVS_REM' ||'( '||SUM(DECODE( INSUFF_PRIVS_REM,'Y',1,0))||')') ||decode(max( REMOTE_TRANS_MISMATCH),'Y', ' REMOTE_TRANS_MISMATCH' ||'( '||SUM(DECODE(REMOTE_TRANS_MISMATCH,'Y',1,0))||')') ||decode(max( LOGMINER_SESSION_MISMATCH),'Y', ' LOGMINER_SESSION_MISMATCH' ||'( '||SUM(DECODE(LOGMINER_SESSION_MISMATCH,'Y',1,0))||')') ||decode(max( INCOMP_LTRL_MISMATCH),'Y', ' INCOMP_LTRL_MISMATCH' ||'( '||SUM(DECODE( INCOMP_LTRL_MISMATCH,'Y',1,0))||')') ||decode(max( OVERLAP_TIME_MISMATCH),'Y', ' OVERLAP_TIME_MISMATCH' ||'( '||SUM(DECODE(OVERLAP_TIME_MISMATCH,'Y',1,0))||')') --||decode(max( SQL_REDIRECT_MISMATCH),'Y', ' SQL_REDIRECT_MISMATCH' ||'( '||SUM(DECODE( SQL_REDIRECT_MISMATCH,'Y',1,0))||'' ||decode(max( MV_QUERY_GEN_MISMATCH),'Y', ' MV_QUERY_GEN_MISMATCH' ||'( '||SUM(DECODE(MV_QUERY_GEN_MISMATCH,'Y',1,0))||')') ||decode(max( USER_BIND_PEEK_MISMATCH),'Y', ' USER_BIND_PEEK_MISMATCH' ||'( '||SUM(DECODE(USER_BIND_PEEK_MISMATCH,'Y',1,0))||')') ||decode(max( TYPCHK_DEP_MISMATCH),'Y', ' TYPCHK_DEP_MISMATCH' ||'( '||SUM(DECODE( TYPCHK_DEP_MISMATCH,'Y',1,0))||')') ||decode(max( NO_TRIGGER_MISMATCH),'Y', ' NO_TRIGGER_MISMATCH' ||'( '||SUM(DECODE( NO_TRIGGER_MISMATCH,'Y',1,0))||')') ||decode(max( FLASHBACK_CURSOR),'Y', ' FLASHBACK_CURSOR' ||'( '||SUM(DECODE( FLASHBACK_CURSOR,'Y',1,0))||')') ||decode(max( ANYDATA_TRANSFORMATION),'Y', ' ANYDATA_TRANSFORMATION' ||'( '||SUM(DECODE(ANYDATA_TRANSFORMATION,'Y',1,0))||')') --||decode(max( INCOMPLETE_CURSOR),'Y', ' INCOMPLETE_CURSOR' ||'( '||SUM(DECODE( INCOMPLETE_CURSOR,'Y',1,0))||'' ||decode(max( TOP_LEVEL_RPI_CURSOR),'Y', ' TOP_LEVEL_RPI_CURSOR' ||'( '||SUM(DECODE( TOP_LEVEL_RPI_CURSOR,'Y',1,0))||')') ||decode(max( DIFFERENT_LONG_LENGTH),'Y', ' DIFFERENT_LONG_LENGTH' ||'( '||SUM(DECODE(DIFFERENT_LONG_LENGTH,'Y',1,0))||')') ||decode(max( LOGICAL_STANDBY_APPLY),'Y', ' LOGICAL_STANDBY_APPLY' ||'( '||SUM(DECODE(LOGICAL_STANDBY_APPLY,'Y',1,0))||')') ||decode(max( DIFF_CALL_DURN),'Y', ' DIFF_CALL_DURN' ||'( '||SUM(DECODE( DIFF_CALL_DURN,'Y',1,0))||')') ||decode(max( BIND_UACS_DIFF),'Y', ' BIND_UACS_DIFF' ||'( '||SUM(DECODE( BIND_UACS_DIFF,'Y',1,0))||')') ||decode(max( PLSQL_CMP_SWITCHS_DIFF),'Y', ' PLSQL_CMP_SWITCHS_DIFF' ||'( '||SUM(DECODE(PLSQL_CMP_SWITCHS_DIFF,'Y',1,0))||')') ||decode(max( CURSOR_PARTS_MISMATCH),'Y', ' CURSOR_PARTS_MISMATCH' ||'( '||SUM(DECODE(CURSOR_PARTS_MISMATCH,'Y',1,0))||')') ||decode(max( STB_OBJECT_MISMATCH),'Y', ' STB_OBJECT_MISMATCH' ||'( '||SUM(DECODE( STB_OBJECT_MISMATCH,'Y',1,0))||')') --||decode(max( ROW_SHIP_MISMATCH),'Y', ' ROW_SHIP_MISMATCH' ||'( '||SUM(DECODE( ROW_SHIP_MISMATCH,'Y',1,0))||'' ||decode(max( PQ_SLAVE_MISMATCH),'Y', ' PQ_SLAVE_MISMATCH' ||'( '||SUM(DECODE( PQ_SLAVE_MISMATCH,'Y',1,0))||')') ||decode(max( TOP_LEVEL_DDL_MISMATCH),'Y', ' TOP_LEVEL_DDL_MISMATCH' ||'( '||SUM(DECODE(TOP_LEVEL_DDL_MISMATCH,'Y',1,0))||')') ||decode(max( MULTI_PX_MISMATCH),'Y', ' MULTI_PX_MISMATCH' ||'( '||SUM(DECODE( MULTI_PX_MISMATCH,'Y',1,0))||')') ||decode(max( BIND_PEEKED_PQ_MISMATCH),'Y', ' BIND_PEEKED_PQ_MISMATCH' ||'( '||SUM(DECODE(BIND_PEEKED_PQ_MISMATCH,'Y',1,0))||')') ||decode(max( MV_REWRITE_MISMATCH),'Y', ' MV_REWRITE_MISMATCH' ||'( '||SUM(DECODE( MV_REWRITE_MISMATCH,'Y',1,0))||')') ||decode(max( ROLL_INVALID_MISMATCH),'Y', ' ROLL_INVALID_MISMATCH' ||'( '||SUM(DECODE(ROLL_INVALID_MISMATCH,'Y',1,0))||')') ||decode(max( OPTIMIZER_MODE_MISMATCH),'Y', ' OPTIMIZER_MODE_MISMATCH' ||'( '||SUM(DECODE(OPTIMIZER_MODE_MISMATCH,'Y',1,0))||')') ||decode(max( PX_MISMATCH),'Y', ' PX_MISMATCH' ||'( '||SUM(DECODE( PX_MISMATCH,'Y',1,0))||')') ||decode(max( MV_STALEOBJ_MISMATCH),'Y', ' MV_STALEOBJ_MISMATCH' ||'( '||SUM(DECODE( MV_STALEOBJ_MISMATCH,'Y',1,0))||')') ||decode(max( FLASHBACK_TABLE_MISMATCH),'Y', ' FLASHBACK_TABLE_MISMATCH' ||'( '||SUM(DECODE(FLASHBACK_TABLE_MISMATCH,'Y',1,0))||')') ||decode(max( LITREP_COMP_MISMATCH),'Y', ' LITREP_COMP_MISMATCH' ||'( '||SUM(DECODE( LITREP_COMP_MISMATCH,'Y',1,0))||')') reason, SYSDATE from gv$sql_shared_cursor where sql_id in (select sql_id from (select sql_id , count(*) from (select sql_id, plan_hash_value, count(*) from gv$sqlarea group by SQL_ID , plan_hash_value ORDER BY 3 DESC ) group by sql_id having count(*)>2 order by 2 desc )) group by sql_id; END; / ++++++++++++++++++++++++ Query to check Team usage : select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig from DBA_HIST_ACTIVE_SESS_HISTORY where sample_time > sysdate-3 and TEMP_SPACE_ALLOCATED > (100*1024*1024*1024) group by sql_id order by sql_id; from Josh Arora (Cisco) to everyone: 9:34 PM INC6160564 - PDBPROD from Josh Arora (Cisco) to everyone: 9:35 PM INC6142247 - Observing slowness in GTM --- TCPM Socket from Madan Kumar Kancharla (Cisco) to everyone: 9:46 PM INC6159812 /*+ INDEX(v_employees.employees IDX_emp_id) */ ******** /*+ INDEX(v_employees employees IDX_emp_id) */ ************** For request id given : SELECT A.REQUEST_ID, D.SID, D.SERIAL# , C.SPID,A.PHASE_CODE 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 = &REQUEST_ID ---AND A.PHASE_CODE = ‘R’; ============= INC0674838 ---- ---- prem/suraj G2CPRD /*+ materialize */ Bangalore Duo - SSL ===== use this to connect VPN (now)(adi and shilpa are using) === previously using Bangalore gem vpn 2 (Bangalore GEM VPN 2) ==== at hyd team told to use ==== Bangalore gem 2 DUO(BGL GEM 2 DUO) ===== +++++++++++++++++++ AWR snapshots for upgrde : Step 1 :- /* Formatted on 30-07-2021 12:10:58 (QP5 v5.294) */ SELECT DISTINCT CONCURRENT_PROGRAM_ID, MIN (TIME), MAX (TIME), AVG (TIME) FROM (SELECT Concurrent_program_id, ROUND ( (actual_completion_date - actual_start_date) * 24 * 60 * 60, 2) time FROM apps.fnd_concurrent_requests WHERE ACTUAL_START_DATE BETWEEN TO_DATE ('07/28/2021 00:00:00', 'MM/DD/RRRR HH24:MI:SS') AND TO_DATE ('07/28/2021 04:00:00', 'MM/DD/RRRR HH24:MI:SS')) GROUP BY CONCURRENT_PROGRAM_ID; /* Formatted on 03/08/2021 18:19:11 (QP5 v5.294) */ SELECT DISTINCT DV1.program_id, PRD.program_name, DV1.min_time, DV1.max_time, DV1.Avg_time, PRD.min_time, PRD.max_time, PRD.avg_time FROM dv1cl1_28july DV1, CL1PRD_28JULY PRD WHERE DV1.PROGRAM_ID = PRD.PROGRAM_ID -- GROUP BY DV1.PROGRAM_ID ; UPDATE cl1prd_28july bb set program_name = ( select distinct AA.USER_CONCURRENT_PROGRAM_NAME from apps.fnd_concurrent_programs_tl AA where to_number (AA.concurrent_program_id ) = to_number (program_id) +++++++++++++++++++++++++++++++++ suraj select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id -- AND s.sid = 5756 --AND s.inst_id = 1 AND s.sql_id = '63tnpagfcwchh' -- AND substr(m.status,1,4) = 'EXEC' and m.sql_exec_id= 150998576 AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id select sql_exec_id from gv$sql_plan_monitor where sql_id = '63tnpagfcwchh' order by output_rows desc -- get the sql exec id Hi, The concurrent job "Cisco TSL FCM Rec Interface Extract" in G2CPRD is continuously failing . Please find attached the TRACE files from a recent execution. Could you please help us figure out the reason for this issue. Please note that I have attached the Trace files from G2CPRD as well as ODSPROD since the job calls a package in SCAADM@ODSPROD. Feel free to revert if you need further information. Regards, Ciciliya ============ Performance Tuning (Standalone and RAC): 1. Database Performance Issue 2. AWR – How to read 3. ASH – How to read 4. System State Dump – How to capture and how to read them 5. 10046/10053/error stack 6. RAC specific database tuning parameters 7. Automatic SQL Tuning 8. Tools 9. Identifying and Tuning SQL Problems 10. ADDM 11. Tuning SQL & Tuning Optimizer and Execution Plan 12. Recommendations or Suggestions 13. Other Tools 14. Some frequently asked questions PL/SQL lock timer Run this and tell me the output - SELECT vs.inst_id,vs.osuser,vw.event,vw.p1,vw.p2,vw.p3 ,vt.sql_text , vs.program FROM gv$session_wait vw, gv$sqltext vt , gv$session vs WHERE vw.event = 'PL/SQL lock timer' AND vt.address=vs.sql_address AND vs.inst_id = vw.inst_id AND vs.sid = vw.sid; Its acvross miultiple INST_ID OSUSER EVENT P1 P2 P3 SQL_TEXT PROGRAM ---------- ------------------------------ ---------------------------------------------------------------- ---------- ---------- ---------- ---------------------------------------------------------------- ------------------------------------------------ 8 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 3 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 5 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 2 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 9 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 4 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 1 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 7 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 10 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 6 oracle PL/SQL lock timer 0 0 0 BEGIN dbms_lock.sleep(60); END; JDBC Thin Client 10 rows selected. select osuser,event,p1 from gv$session where event = 'PL/SQL lock timer'; 05:37:17 SQL> select osuser,event,p1 from gv$session where event = 'PL/SQL lock timer'; OSUSER EVENT P1 ------------------------------ ---------------------------------------------------------------- ---------- oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 oracle PL/SQL lock timer 0 select time_waited from gv$system_event where event = 'PL/SQL lock timer';05:39:22 SQL> TIME_WAITED ----------- 220204867 397946472 397956417 397942965 397948362 397946252 397942670 397945583 397946523 397939424 10 rows selected. SELECT s.sid, s.seconds_in_wait, s.wait_class, s.event, s.p1text, s.p1, s.p1raw, s.serial#, s.program, s.client_identifier, s.terminal, s.command, ct.command_name, s.service_name, s.module, s.action, s.username, s.machine, s.sql_id, st.sql_text, -- just the first 64 characters of the SQL text st.hash_value FROM gv$session s, gv$sqltext st, gv$sqlcommand ct WHERE st.sql_id (+) = s.sql_id AND st.piece (+) = 0 AND ct.command_type (+) = s.command AND s.event = 'PL/SQL lock timer' ORDER BY s.seconds_in_wait DESC; Best way to fix this is grant public to all users This event is called through the DBMSLOCK.SLEEP procedure or USERLOCK.SLEEP procedure. This event is most likely to come from user written stored procedures. pushed back to the application support team to amend the code to reduce the amount of time this particular job spent sleeping. This is not our issue the issue is with application code for sure GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP; or you can tell dba to perform - GRANT EXECUTE ON SYS.DBMS_LOCK TO PUBLIC; for now But this is just. STF the permanent fix is to fix the actual code which needs to be taken care of by the application developers I checked across all the rac nodes this is caused due to dbsmnp account GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP; This is the stf Run this command in the database as STF GRANT EXECUTE ON SYS.DBMS_LOCK TO DBSNMP; Once the work is completed then dba needs to revoke it They need to be careful doing revoke as it has an issue Revoke Execute on SYS.DBMS_LOCK Errors With 'ORA-04021: timeout occurred while waiting to lock object' (Doc ID 2295290.1) This is an expected behavior for explicit DDL commands...in case of revoke,it cannot leave other objects of the same user in inconsistent state. Hence, it can not go through with exclusive lock. If the same execute was granted via the role, only have to revoke the role and it will succeed. This is expected behavior. If they run into that issue while doing the REVOKE the solution is as follows - 1. Run revoke command when there is no transactions on the database. Precisely when there is no session/transaction using the SYS.DBMS_LOCK package or 2. Open the database in restrict mode per Document 337469.1 so that there will not be any user actions which could hold SYS.DBMS_LOCK ==================== Top sql for ASH in 19C : ========================== SELECT sql_id, sql_plan_hash_value plan_hash_value, (SELECT username FROM dba_users WHERE user_id = ash.user_id) schema, MAX (program) program, MAX (module) module, MAX (action) action, MAX (machine) machine, COUNT (*) snapcount -- (select program_id from gv$sql where sql_id=ash.sql_id and rownum =1) obj_id, -- (select o.object_name from perftest_objects o, gv$sql s where s.program_id =o.object_id and s.sql_id=ash.sql_id ) object_name, -- (select program_line# from gv$sql where sql_id=ash.sql_id and rownum =1) line# FROM dba_hist_active_sess_history ash, ( SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid FROM dba_hist_snapshot WHERE (begin_interval_time) BETWEEN TO_DATE (20210728000000, 'YYYYMMDDHH24MISS') AND TO_DATE (20210728043000, 'YYYYMMDDHH24MISS') GROUP BY dbid) snap WHERE ash.snap_id >= snap.min_snap_id AND snap_id <= snap.max_snap_id AND snap.dbid = ash.dbid AND user_id != 0 AND sql_plan_hash_value != 0 AND instance_number = :inst_id AND user_id NOT IN (SELECT user_id FROM dba_users WHERE username IN ('PERF11I', 'OPS$ORACLE', 'SYS', 'CISCO$SECURITY', 'DBSNMP')) AND machine NOT LIKE '%CISCO%' AND client_id NOT IN ('SYSTEM') AND module NOT LIKE '%SYSADMIN%' AND session_type = 'FOREGROUND' GROUP BY sql_id, sql_plan_hash_value, user_id ORDER BY COUNT (*) DESC --FETCH FIRST 30 ROWS ONLY SQL * net from db link : ========================== http://www.dba-oracle.com/t_sql_dblink_performance.htm https://shaharear.blogspot.com/2009/02/drivingsite-sql-hint.html http://www.moreajays.com/2013/01/sqlnet-message-to-dblink-sqlnet-message.html ****** main https://msutic.blogspot.com/2011/02/sqlnet-message-tofrom-dblink-how-to.html Query to check whether its Reading from UNdo/Not : ================================================= select EVENT,CURRENT_OBJ# , OBJECT_NAME , SUBOBJECT_NAME , OBJECT_TYPE , f.tablespace_name ,COUNT(*) from dba_hist_active_sess_history , dba_objects d , dba_data_files f where session_id =2693 and session_serial# =51184 and sql_id = '59fwvsqhk234t' and snap_id between 160335 and 160357 AND d.object_id(+) = CURRENT_OBJ# and f.file_id = p1 GROUP BY EVENT,CURRENT_OBJ# , OBJECT_NAME , SUBOBJECT_NAME , OBJECT_TYPE, f.tablespace_name ORDER BY COUNT(*) DESC; (****************** Caller: Mohit Amgaonkar (mamgaonk) Service Offering: Oracle Database Summary: SVSPRD APPCLOUD schema data migration Severity: 3 - Low Priority: 5 - Standard To check snapping : SELECT MIN (snap_id), MAX (snap_id) begin_interval_time from dba_hist_snapshot WHERE begin_interval_time BETWEEN TO_DATE ('10/18/2021 16:00:00','MM/DD/YYYY HH24:MI:SS') AND TO_DATE ('10/18/2021 18:00:00', 'MM/DD/YYYY HH24:MI:SS'); ---- MIN(SNAP_ID) BEGIN_INTERVAL_TIME 81670 81673 Query to get Top 100 Cpu SQL : +++++++++++++++++++++++++++++ select * from (select s.sql_id, RANK() OVER (ORDER BY (max(s.CPU_TIME_TOTAL/s.executions_total)) DESC) cpu_rank, RANK() OVER (ORDER BY (max(s.ELAPSED_TIME_TOTAL/s.EXECUTIONS_TOTAL)) DESC) elapsed_rank from dba_hist_sqlstat s, dba_hist_snapshot sn where sn.begin_interval_time between to_date('03-mar-2022 0001','dd-mon-yyyy hh24mi') and to_date('05-apr-2022 1100','dd-mon-yyyy hh24mi') and sn.snap_id=s.snap_id and s.executions_total >0 group by s.sql_id ) where cpu_rank <=100 and elapsed_rank<=100; select begin_interval_time FROM dba_hist_snapshot where snap_id=105890 ***************** HOST_NAME --- svs prd ==== 19.0.0.0.0 Old ---- dbc-prd2-2060 dbc-prd2-2058 dbc-prd2-2059 dbc-prd2-2057 New ---- ************ dbc-prd1-2060 dbc-prd1-2058 dbc-prd1-2059 dbc-prd1-2057 *************************************** G2CPRD : 12.1.0.2.0 HOST_NAME dbc-prd1-2053 dbc-prd1-2052 dbc-prd1-2051 dbc-prd1-2054 coverage team: wip-coverage-support(mailer list) <wip-coverage-support@cisco.com> Rohit Pal -X (rohpal - WIPRO LIMITED at Cisco) Utpalendu Karmakar -X (ukarmaka - WIPRO LIMITED at Cisco) Shaik Tamzum -X (stamzum - WIPRO LIMITED at Cisco) otm-crediting : wip-otm-crediting-support(mailer list) Pravin Kumar -X (pravink3 - WIPRO LIMITED at Cisco) Satheshkumar Murugan -X (sathesmu - WIPRO LIMITED at Cisco) Keshav Mittal -X (kemittal - WIPRO LIMITED at Cisco) Mancherla Jaswanth Reddy -X (mancredd - WIPRO LIMITED at Cisco) OIC : wipro_oic_support(mailer list) Kottisa Sai -X (kotsai - WIPRO LIMITED at Cisco) (OIC) for OIC Oracle Incentive Compensation (OIC) ---- SO GSE-GTMS-G2C-OIC-SME --- PM GSE-GTMS-G2C-OIC --- AG Kottisa Sai (kotsai) --- POC ==== NGCGi Team khota@cisco.com nehaag@cisco.com knatolan@cisco.com Schema :XXG2CCGI POC : wip-otm-crediting-support(mailer list) <wip-otm-crediting-support@cisco.com>; wip-coverage-support(mailer list) <wip-coverage-support@cisco.com>; wipro_oic_support(mailer list) <wipro_oic_support@cisco.com> https://cisco.sharepoint.com/sites/ApplicationPerformanceManagement-DBSQLTuning ********** Link shared By Manish(for Docs) Tuning Database Instance Proactively Using ADDM Infrastructure : =============================================================== Going forward we can use the following customized query to report out all issues that need attention to improve your overall database performance based on different criteria: impact, rank, problem type etc... The goal is to utilize Automatic Database Diagnostic Monitor (ADDM) infrastructure to help tune database instance problems/issues based on rank and impact and/or problem type. SELECT a.Execution_end, b.Type, b.Impact, d.Rank, d.Type, 'Message : ' ||b.Message Message, 'Command To correct: ' ||c.Command Command, 'Action Message : ' ||c.Message Action_Message FROM DBA_Advisor_Tasks a, DBA_Advisor_Findings b, DBA_Advisor_Actions c, DBA_Advisor_Recommendations d WHERE a.Owner=b.Owner AND a.Task_ID = b.Task_ID AND b.Task_ID = d.Task_ID AND b.Finding_ID = d.Finding_ID AND a.Task_ID = c.Task_Id AND d.Rec_ID = c.Rec_ID AND a.Task_Name LIKE 'ADDM%' AND a.Status='COMPLETED' Order By BY b.Impact, d.Rank An example output is presented below: Execution End : 18-NOV-16 Type : Problem Impact : 4.4961E+10 Rank : 2 Type : SQL Tuning Message : SQL statements consuming significant database time were found. These statements offer a good opportunity for performance improvement. Command To correct : RUN SQL TUNING ADVISOR Action Message : Run SQL Tuning Advisor on the SELECT statement with SQL_ID "9wm3snv9jw4ng". Execution End : 29-NOV-16 Type : Problem Impact : 7522162 Rank : 2 Type : Application Analysis Message : Waits on event "log file sync" while performing COMMIT and ROLLBACK operations were consuming significant database time. Command To correct : UNDEFINED Action Message : Investigate application logic for possible reduction in the number of COMMIT operations by increasing the size of transactions. Cheers Josh *************************** INC3403444 Also, SIAPRD seems to have a lot of User IO issues and many queries need tuning. SIAPRD CTMPRD management could consider subscribing to performance team for proactive services (top sql analysis, host analysis and weekly/ bi-weekly meetings) by sending mail to perf-engage(mailer list). 30 10 * * 6 /auto/hosting/bin/Oracle/database/GatherStats/PRD/GatherStats.pl -i OTMPRD1 -d WEEKEND -x MANUAL 30 10 * * 0-5 /auto/hosting/bin/Oracle/database/GatherStats/PRD/GatherStats.pl -i OTMPRD1 -d WEEKDAY -x MANUAL select * from gv$session where status='INACTIVE' and schemaname='SCD' and OSUSER='engadm' ****************** =============== Hi Team, As suggested gathered Histogram On VT_STATUS SQL> / Enter value for table_name: XXCP_VT_INTERFACE Enter value for column_name: VT_STATUS old 1: select owner,table_name,column_name,histogram,last_analyzed from DBA_TAB_COL_STATISTICS where table_name='&table_name' and column_name='&column_name' new 1: select owner,table_name,column_name,histogram,last_analyzed from DBA_TAB_COL_STATISTICS where table_name='XXCP_VT_INTERFACE' and column_name='VT_STATUS' OWNER TABLE_NAME COLUMN_NAME -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- HISTOGRAM LAST_ANALYZED --------------- ------------------ XXCP XXCP_VT_INTERFACE VT_STATUS HEIGHT BALANCED 24-FEB-21 the analyze is done and histogram is created After that clear the cache and Re Run the Program and it Got completed as before Issue Got fixed and Resolving the case. Regards Madan ======================================================== SELECT COLUMN_NAME, NOTES, HISTOGRAM 2 FROM USER_TAB_COL_STATISTICS 3 WHERE TABLE_NAME = 'SALES2'; SQL> SELECT COUNT(*) FROM sales2 WHERE prod_id = 42; COUNT(*) ---------- 12116 SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER,'SALES2',OPTIONS=>'GATHER AUTO'); ========= SQL> select owner,table_name,TO_CHAR(last_analyzed,'MM/DD/YYYY HH:MI:SS') Last_Analyzed, global_stats from dba_tables where TABLE_NAME='OBJECT_LOCK'; OWNER TABLE_NAME LAST_ANALYZED GLOBAL_STATS ------------------------------ ------------------------------ ------------------------------------------------------------------------------------------ ------------------------------ GLOGOWNER OBJECT_LOCK 04/24/2021 10:32:04 YES select event,sql_id, a.* from gv$session a where username = 'SCD' ************* An Ad-Hoc Query is a query that cannot be determined prior to the moment the query is issued. It is created in order to get information when need arises and it consists of dynamically constructed SQL which is usually constructed by desktop-resident query tools https://cisco.sharepoint.com/sites/ApplicationPerformanceManagement-DBSQLTuning/Shared%20Documents/Forms/AllItems.aspx ==== share your analysis over mail - 1) why leading hint caused query to run longer in TS1? 2)What are the alternate options. 3) Why in original query maximum filtering was happening after xla_ae_headers, is it a combination of tables that cause filtering? Please do make statement fix entry for the yesterday sqls of CG1PRD which has been worked upon You can use below link for it http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp ************ Statement fix entry IO waits then plan check each part of the query to find where exactly the issue issues ---- -- Check who is blocking who in RAC, including objects SELECT DECODE(request,0,'Holder: ','Waiter: ') || gv$lock.sid sess, machine, do.object_name as locked_object,id1, id2, lmode, request, gv$lock.type FROM gv$lock join gv$session on gv$lock.sid=gv$session.sid and gv$lock.inst_id=gv$session.inst_id join gv$locked_object lo on gv$lock.SID = lo.SESSION_ID and gv$lock.inst_id=lo.inst_id join dba_objects do on lo.OBJECT_ID = do.OBJECT_ID WHERE (id1, id2, gv$lock.type) IN ( SELECT id1, id2, type FROM gv$lock WHERE request>0) ORDER BY id1, request; SESS MACHINE ------------------------------------------------ ---------------------------------------------------------------- LOCKED_OBJECT ID1 ID2 -------------------------------------------------------------------------------------------------------------------------------- ---------- ---------- LMODE REQUEST TY ---------- ---------- -- Holder: 1602 npr-prd-107 COLL_ENTITY_ENTPHYSICAL 66584577 2588339 6 0 TX Waiter: 3195 npr-prd-103 COLL_ENTITY_ENTPHYSICAL 66584577 2588339 0 6 TX ============== -- Who is blocking who, with some decoding********************* select OS_USER_NAME os_user, PROCESS os_pid, ORACLE_USERNAME oracle_user, l.SID oracle_id, decode(TYPE, 'MR', 'Media Recovery', 'RT', 'Redo Thread', 'UN', 'User Name', 'TX', 'Transaction', 'TM', 'DML', 'UL', 'PL/SQL User Lock', 'DX', 'Distributed Xaction', 'CF', 'Control File', 'IS', 'Instance State', 'FS', 'File Set', 'IR', 'Instance Recovery', 'ST', 'Disk Space Transaction', 'TS', 'Temp Segment', 'IV', 'Library Cache Invalidation', 'LS', 'Log Start or Switch', 'RW', 'Row Wait', 'SQ', 'Sequence Number', 'TE', 'Extend Table', 'TT', 'Temp Table', type) lock_type, decode(LMODE, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive', lmode) lock_held, decode(REQUEST, 0, 'None', 1, 'Null', 2, 'Row-S (SS)', 3, 'Row-X (SX)', 4, 'Share', 5, 'S/Row-X (SSX)', 6, 'Exclusive', request) lock_requested, decode(BLOCK, 0, 'Not Blocking', 1, 'Blocking', 2, 'Global', block) status, OWNER, OBJECT_NAME from v$locked_object lo, dba_objects do, v$lock l where lo.OBJECT_ID = do.OBJECT_ID AND l.SID = lo.SESSION_ID and block=1 To check Blocking sessions : ----------------------------- select * from gv$lock where block=1; select count(*) from gv$lock where block=1; select sid from gv$lock where block=1; Result set : OS_USER OS_PID ORACLE_USER ORACLE_ID LOCK_TYPE LOCK_HELD LOCK_REQUESTED STATUS OWNER OBJECT_NAME -------------------------------------------------------------------------------------------------------------------------------- ------------------------ -------------------------------------------------------------------------------------------------------------------------------- ---------- -------------------------- ---------------------------------------- ---------------------------------------- ---------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- netaware 28780 NETAWARE 708 Transaction Exclusive None Blocking NETAWARE script to find best Plan for the query : ======================================== set lines 155 col execs for 999,999,999 col etime for 999,999,999.9 col avg_etime for 999,999.999 col avg_cpu_time for 999,999.999 col avg_lio for 999,999,999.9 col avg_pio for 9,999,999.9 col begin_interval_time for a30 col node for 99999 break on plan_hash_value on startup_time skip 1 select sql_id, plan_hash_value, sum(execs) execs, -- sum(etime) etime, sum(etime)/sum(execs) avg_etime, sum(cpu_time)/sum(execs) avg_cpu_time, sum(lio)/sum(execs) avg_lio, sum(pio)/sum(execs) avg_pio from ( select ss.snap_id, ss.instance_number node, begin_interval_time, sql_id, plan_hash_value, nvl(executions_delta,0) execs, elapsed_time_delta/1000000 etime, (elapsed_time_delta/decode(nvl(executions_delta,0),0,1,executions_delta))/1000000 avg_etime, buffer_gets_delta lio, disk_reads_delta pio, cpu_time_delta/1000000 cpu_time, (buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta)) avg_lio, (cpu_time_delta/decode(nvl(executions_delta,0),0,1,executions_delta)) avg_cpu_time from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS where sql_id = nvl('&sql_id','0j60rcf1sxwhn') and ss.snap_id = S.snap_id and ss.instance_number = S.instance_number -- and executions_delta > 0 ) group by sql_id, plan_hash_value order by 5 / Note : Click f5 and pass sql (in query also) O/p: SQL_ID PLAN_HASH_VALUE EXECS AVG_ETIME AVG_CPU_TIME AVG_LIO AVG_PIO ------------- --------------- ------------ ------------ ------------ -------------- ------------ 0j60rcf1sxwhn 1533718691 10 533.394 496.778 35,370,800.1 101,565.9 0j60rcf1sxwhn 2723961532 40 535.300 502.510 35,673,460.0 92,993.1 0j60rcf1sxwhn 976736611 1,322 596.614 520.524 36,311,123.0 326,966.5 0j60rcf1sxwhn 4048717372 151 565.509 523.587 36,539,770.6 101,053.9 0j60rcf1sxwhn 4058400253 649 565.257 525.656 36,787,799.1 102,553.3 0j60rcf1sxwhn 1482650650 435 603.618 532.059 36,580,169.4 351,073.9 0j60rcf1sxwhn 3087887237 91 575.177 534.807 36,833,093.6 103,455.5 0j60rcf1sxwhn 2630151508 4 609.285 538.745 35,620,276.3 352,627.3 0j60rcf1sxwhn 3604316931 486 620.117 543.302 37,384,418.4 360,170.0 0j60rcf1sxwhn 2932537873 1 585.594 543.806 35,661,039.0 110,443.0 0j60rcf1sxwhn 3099395911 453 637.179 550.498 37,488,353.2 356,781.2 0j60rcf1sxwhn 1754400160 97 598.251 553.059 37,493,150.8 107,679.8 ========== To Know at which Object in the query consuming max time SELECT ash.sql_plan_line_id, ash.sql_plan_operation, ash.sql_plan_options, p.object_name, round(100*COUNT(*)/ sum(count(1)) over(), 2) "% time" FROM gv$active_session_history ash, gv$sql_plan p WHERE ash.sql_id = p.sql_id AND ash.sql_plan_hash_value = p.plan_hash_value AND ash.sql_plan_line_id = P.id AND ash.sql_id = '&sql_id' AND ash.sql_plan_hash_value = &plan_hash_value GROUP BY ASH.SQL_PLAN_LINE_ID, ASH.SQL_PLAN_OPERATION, ASH.SQL_PLAN_OPTIONS, p.object_name ORDER BY count(*) DESC / ---- SELECT ash.sql_plan_line_id, ash.sql_plan_operation, ash.sql_plan_options, p.object_name, round(100*COUNT(*)/ sum(count(1)) over(), 2) "% time" FROM dba_hist_active_sess_history ash, gv$sql_plan p WHERE ash.sql_id = p.sql_id AND ash.sql_plan_hash_value = p.plan_hash_value AND ash.sql_plan_line_id = P.id AND ash.sql_id = '&sql_id' AND ash.sql_plan_hash_value = &plan_hash_value GROUP BY ASH.SQL_PLAN_LINE_ID, ASH.SQL_PLAN_OPERATION, ASH.SQL_PLAN_OPTIONS, p.object_name ORDER BY count(*) DESC / ------------------------------------- SELECT ash.sql_plan_line_id, ash.sql_plan_operation, ash.sql_plan_options, p.object_name, round(100*COUNT(*)/ sum(count(1)) over(), 2) "% time" FROM dba_hist_active_sess_history ash, dba_hist_sql_plan/gv$sql_plan/xxcpf_pm_sql_plan p WHERE ash.sql_id = p.sql_id AND ash.sql_plan_hash_value = p.plan_hash_value AND ash.sql_plan_line_id = P.id AND ash.sql_id = '&sql_id' AND ash.sql_plan_hash_value = &plan_hash_value GROUP BY ASH.SQL_PLAN_LINE_ID, ASH.SQL_PLAN_OPERATION, ASH.SQL_PLAN_OPTIONS, p.object_name ORDER BY count(*) DESC / ------------- SELECT ash.sql_plan_line_id, ash.sql_plan_operation, ash.sql_plan_options, p.object_name, round(100*COUNT(*)/ sum(count(1)) over(), 2) "% time" FROM dba_hist_active_sess_history ash, dba_hist_sql_plan p WHERE ash.sql_id = p.sql_id AND ash.sql_plan_hash_value = p.plan_hash_value AND ash.sql_plan_line_id = P.id AND ash.sql_id = '&sql_id' AND ash.sql_plan_hash_value = &plan_hash_value GROUP BY ASH.SQL_PLAN_LINE_ID, ASH.SQL_PLAN_OPERATION, ASH.SQL_PLAN_OPTIONS, p.object_name ORDER BY count(*) DESC / -------- O/p : SQL_PLAN_LINE_ID SQL_PLAN_OPERATION SQL_PLAN_OPTIONS OBJECT_NAME % time 108 TABLE ACCESS FULL DRF_CONTACT 46.43 32 TABLE ACCESS FULL DRF_CONTACT 40.66 169 SORT GROUP BY PIVOT 6.86 93 SORT GROUP BY PIVOT 5.23 https://cisco-my.sharepoint.com/:x:/p/vinandag/EWBT2oJumolGsJXV4jd6-pEBaOU5w8l_S9mVcAtwLhDNuQ?e=ZkaJsi -----***** PBI Tracker =============== HOST_NAME --- svs prd ==== 19.0.0.0.0 Old ---- dbc-prd2-2060 dbc-prd2-2058 dbc-prd2-2059 dbc-prd2-2057 New ---- dbc-prd1-2060 dbc-prd1-2058 dbc-prd1-2059 dbc-prd1-2057 ========================================== sqlplus "/ as sysdba" SQL> oradebug setmypid SQL> oradebug unlimit; SQL> oradebug -g all hanganalyze 3 --wait for 30sec ------------ SQL> oradebug -g all hanganalyze 4 SQL> oradebug -g all systemstate 258 SQL> oradebug -g all systemstate 258 SQL> oradebug tracefile_name SQL> exit ============================================================= SVSPRD : Shruthi Basavaraju -X (shrubasa - TATA CONSULTANCY SERVICES LIMITED at Cisco) <shrubasa@cisco.com>; Mark this Mailer alias gsqs-csit-support(mailer list) gsqs-csit-support@cisco.com ----======== ===========To Know where exactly query spending time select nvl(event, session_state) event, round(100*count(*)/ (sum(count(1)) over ()), 2) "% query time" from dba_hist_active_sess_history where sql_id = '&sql_id' group by nvl(event, session_state) order by count(*) desc O/p : EVENT % query time ON CPU 90.74 direct path read temp 6.19 direct path write temp 1.82 db file sequential read 0.59 ======= To check Historic SQL and its wait event for specifc interval select sql_id,count(*) from dba_hist_active_sess_history where sample_time between to_date('07-NOV-19 18:00:00','DD-MON-YY HH24:MI:SS') and to_date('04-DEC-19 21:00:00','DD-MON-YY HH24:MI:SS') and event = '&event' group by sql_id / ========To check elapse time select SQL_ID , PLAN_HASH_VALUE , sum(EXECUTIONS_DELTA) EXECUTIONS , sum(ROWS_PROCESSED_DELTA) CROWS , trunc(sum(CPU_TIME_DELTA)/1000000/60) CPU_MINS , trunc(sum(ELAPSED_TIME_DELTA)/1000000/60) ELA_MINS from DBA_HIST_SQLSTAT where SQL_ID in ( '&sqlid') group by SQL_ID , PLAN_HASH_VALUE order by SQL_ID, CPU_MINS ======================== PROMPT Session LongOps ========================= SELECT a.sid, RPAD (a.opname, 30), a.sofar, a.totalwork, a.ELAPSED_SECONDS, ROUND ( ( (a.sofar) * 100) / a.totalwork, 3) "%_COMPLETED", time_remaining, RPAD (a.username, 10) username, a.SQL_HASH_VALUE, B.STATUS FROM GV$SESSION_LONGOPS a, gv$session b WHERE a.sid = &sid AND b.inst_id = &inst_id AND b.serial# = &serial AND a.sofar <> a.totalwork / ******************** SVSPRD : Shruthi Basavaraju -X (shrubasa - TATA CONSULTANCY SERVICES LIMITED at Cisco) <shrubasa@cisco.com>; edps-performance(mailer list) <edps-performance@cisco.com> select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from v$session_longops where SID='5503'; SID SERIAL# OPNAME SOFAR TOTALWORK TIME_REMAINING ---------- ---------- ---------------------------------------------------------------- ---------- ---------- -------------- 5503 57145 Table Scan 67914 9647634 2472582 Hi Team, Could you please share the session details of last quarter run It would be helpful for the analysis . As per the history of the SQL , we could see only one entry in history of the SQL. Thanks & Regards, select count(*) from PROFILE_ATTRIBUTE_VALUES@CPRRO_PRD --366058323 -- last 5days select count(*) from ATTRIBUTE_DEFINITIONS@CPRRO_PRD --344 select count(*) from PERSONS@CPRRO_PRD cp --25504064 select count(*) from PROFILES@CPRRO_PRD cprof --25504086 plan_has wise high IO : ======================== SELECT q.plan_hash_value,max(q.sql_id) sql_id, Q.DBID, (select reference from xxcpf_pm_sql_statement_fix where hash_value = q.plan_hash_value and rownum = 1 ) case_sql_hash_1, SUM (q.EXECUTIONS_DELTA) executions, SUM (DISK_READS_delta + DIRECT_WRITES_delta) pio_total, SUM ((PHYSICAL_READ_BYTES_DELTA + PHYSICAL_WRITE_BYTES_DELTA) / (1024 *1024*1024)) PIO_GB , ROUND (SUM (DISK_READS_delta + DIRECT_WRITES_delta) / GREATEST (SUM (executions_delta), 1), 1) pio_per_exec, parsing_schema_name, MODULE FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE 1 =1 AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number and q.instance_number = :inst_id AND q.plan_hash_value != 0 AND s.begin_interval_time > sysdate - 45 and parsing_schema_name not in ('PERF11I','OPS$ORACLE','SYS','DBSNMP') group by q.plan_hash_value ,parsing_schema_name,Q.DBID, MODULE order by PIO_GB desc fetch first 10 rows only ---dbc-prd2-2107 select sql_id,sql_opname, count(*) from gv$active_session_history where module like '%dbc-prd2-2107%' group by sql_id,sql_opname order by 3 desc select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE')) select * from gv$sql where sql_id='a1pnz8mx41cdv'---dbc-prd2-2107(Host name) select * from dba_db_links where db_link like '%XXCTS_XELUS_CTS%' select * from gv$instance ==== dbc-prd2-2107 create database link "perfctscsf" connect to PERF11I identified by "ts1cts#123#" using 'TS1CTS_SRVC_OTH' ***************** FND stas hi Haresh/Kartika, as discussed please raise a task to ermo exec fnd_stats.load_histogram_cols(action => 'INSERT', appl_id => 401, tabname => 'MTL_CYCLE_COUNT_ENTRIES', colname => 'ENTRY_STATUS_CODE', hsize => '100'); for creating histogram for csfstg and csfprd begin FND_STATS.GATHER_TABLE_STATS ('INV', 'MTL_CYCLE_COUNT_ENTRIES', percent => 10, degree => 20, granularity => 'ALL', INVALIDATE => 'N', cascade => TRUE); end; in case fnd_stats has to gathered manually post histogram creation if not done automatically **************************** ============ plan_has wise high IO : ======================= SELECT q.plan_hash_value,max(q.sql_id) sql_id, Q.DBID, (select reference from xxcpf_pm_sql_statement_fix where hash_value = q.plan_hash_value and rownum = 1 ) case_sql_hash_1, SUM (q.EXECUTIONS_DELTA) executions, SUM (DISK_READS_delta + DIRECT_WRITES_delta) pio_total, SUM ((PHYSICAL_READ_BYTES_DELTA + PHYSICAL_WRITE_BYTES_DELTA) / (1024 *1024*1024)) PIO_GB , ROUND (SUM (DISK_READS_delta + DIRECT_WRITES_delta) / GREATEST (SUM (executions_delta), 1), 1) pio_per_exec, parsing_schema_name, MODULE FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE 1 =1 AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number and q.instance_number = :inst_id AND q.plan_hash_value != 0 AND s.begin_interval_time > sysdate - 45 and parsing_schema_name not in ('PERF11I','OPS$ORACLE','SYS','DBSNMP') group by q.plan_hash_value ,parsing_schema_name,Q.DBID, MODULE order by PIO_GB desc fetch first 10 rows only select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE')) ============= SELECT host_name,inst_id FROM gv$instance; ==== (host name /inst ID) SELECT * FROM dba_hist_sqltext where sql_id in ( '51j8rh3t51x13', ); Gather stats Analyze request for user ( Manually) Hi Umesh/ Team, We are working on the Top SQLs at each Node level. We will share the details Node wise by tomorrow EOD. Thanks & Regards, https://dba.cisco.com/dba-portal/tools/schema-browser/CG1PRD ( TO access all dba link) http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp ============= StatementFix/InsertEntry • https://dba.cisco.com  search with “schema browser”  search/select with schema and select/search object type as table and select/search the table which you want to analyze it • Once the request submitted, it will punch the alert to Prod dashboard (both Prod & Non-Prod) along with link to approve it • Once it is approved, Analyze will submit and requestor will get auto notification once it is approved & analyzed ========== execute dbms_stats.gather_index_stats(ownname => 'CTMRSRV1', indname => 'DBLOG_KEYSTMP', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE); execute dbms_stats.gather_index_stats(ownname => 'CTMRSRV1', indname => 'DBU', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE); execute dbms_stats.gather_table_stats(ownname => 'CTMRSRV1', tabname => 'CMR_DBLOG', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => 'FOR ALL COLUMNS SIZE AUTO'); Please submit gather stats job and check again., =================== How To Find Execution History Of An Sql_id : select a.instance_number inst_id, a.snap_id,a.plan_hash_value, to_char(begin_interval_time,'dd-mon-yy hh24:mi') btime, abs(extract(minute from (end_interval_time-begin_interval_time)) + extract(hour from (end_interval_time-begin_interval_time))*60 + extract(day from (end_interval_time-begin_interval_time))*24*60) minutes, executions_delta executions, round(ELAPSED_TIME_delta/1000000/greatest(executions_delta,1),4) "avg duration (sec)" from dba_hist_SQLSTAT a, dba_hist_snapshot b where sql_id='&sql_id' and a.snap_id=b.snap_id and a.instance_number=b.instance_number order by snap_id desc, a.instance_number; if we have any non-perf related issues, we can route it to below service offering SO:- Technical Help Desk Support Level:- Tier 1 AG: TechSupport-Remote-GSTS-T1 this is what other support teams do Today Suraj Ramchander 12:00 AM anything related to AppDynamics --> Application Performance Management --> APM-MaaS anything related to load testing --> Application Performance Management --> APM-LTaaS ===================== Dear Requester, Thank you for contacting the dba team regarding your Incident/Service Request. We are currently working on your case and will contact you for further information if needed, as well as notify you, when a resolution has been reached. If resolution of the issue is beyond the scope of our support, we will route it to the concerned team. Your patience during resolution process will be greatly appreciated. You can also take a look at the DBA Self-Service URL at: https://dba.cisco.com/dbpharmacy/ Did you know, following tasks can be done easily without a case. :-DB Doppler Utility - To Enable trace. :-DB supplements - To add space to tablespace :-DB Nerve - Validate/create/drop DB Links DB Compiler - View/Compile invalid objects :-DB Cure - To kill sessions :-SSO Login Validation for ERP - validate single sign-on login for ERP database. :-DB Availability Status- Check the availability of status of a DB. :-All About DB - One stop shop for all DB related information :-Analyze as a Self-Service - To Analyze the object :-Check session details, Concurrent requests and terminate unwanted session from the database. Many such useful activities can be done through tool. Please use the self-service tools before opening a case with the DBA teams. You might get the required details readily available through the tool. Thanks, dba-ops-casesupport -- To check given session in a given time frame SELECT /*+ index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ sql_id, SUM ( NVL (NVL (delta_read_io_requests, 0), 0) + NVL (NVL (delta_write_io_requests, 0), 0)) io_requests FROM dba_hist_active_sess_history ash, ( SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid FROM dba_hist_snapshot WHERE TRUNC (begin_interval_time) > SYSDATE - 2 AND TRUNC (begin_interval_time) < SYSDATE + 1 GROUP BY dbid) snap WHERE ash.snap_id >= snap.min_snap_id AND snap_id <= snap.max_snap_id AND snap.dbid = ash.dbid AND ash.session_id = 689 AND ash.session_serial# = 27737 and ash.instance_number= 4 --AND module like '%XXCP_CUSTOM_EVENTS%' GROUP BY sql_id ORDER BY 2 DESC -- To check based on just the module name. *********************** SELECT sql_id, SUM ( NVL (NVL (delta_read_io_requests, 0), 0) + NVL (NVL (delta_write_io_requests, 0), 0)) io_requests FROM gv$active_session_history ash WHERE module like '%XXCP_CUSTOM_EVENTS%' GROUP BY sql_id ORDER BY 2 DESC ======== Hi All, Today is my last working day at Cisco, as I have decided to pursue an opportunity outside. I would like to thank everyone with whom I have worked, helped me to grow and believed in my abilities. I wish you all the very best for your future endeavors and I hope our paths cross again. Please do stay in touch. Rgds Ragesh Monitoring Progress of a SQL Execution Plan : ============================================= column plan_line_id format 9999 heading 'LINE' column plan_options format a10 heading 'OPTIONS' column status format a10 column output_rows heading 'ROWS' break on sid on sql_id on status SELECT sid, sql_id, status, plan_line_id, plan_operation || ' ' || plan_options operation, output_rows FROM v$sql_plan_monitor WHERE status not like '%DONE%' and sid='&sid' <--- ORDER BY 1,4; -- OR --- column plan_line_id format 9999 heading 'LINE' column plan_options format a10 heading 'OPTIONS' column status format a10 column output_rows heading 'ROWS' break on sid on sql_id on status SELECT sid, sql_id, status, plan_line_id, plan_operation || ' ' || plan_options operation, output_rows FROM v$sql_plan_monitor WHERE status not like '%DONE%' ORDER BY 1,4; =============RE: TOP SQL's in CSFPRD 3/9/2021 perf db Hi Umesh/Team, We have completed the Top SQLs analysis w.r.t to CPU usage and High Disk Read consuming SQLs for all 6 Concurrent Nodes. Please find below Key call outs of the analysis. 1) On node 1 , two Spikes has been observed and identified top CPU consuming SQLs for the peak duration . Total 8 problematic SQLs identified on Node 1 which consuming high CPU and disk reads. 2) On Node 2 , CPU usage is 25% through out the duration . No Spikes has been observed . Most of the concurrent program have high executions. 3) On Node 4 , CPU usage is around 25% through out the duration . No spike has been observed , total 3 problematic SQL have encountered on Node 4 which consuming high disk reads. 4) On Node 6 , CPU usage is around 25% through out the duration . No spike has been observed , total 6 problematic SQLs have identified on Node 6 which contributing high disk read and CPU usage. 5) On Node 7 , CPU usage is around 25% through out the duration , No spike has been observed. around 8 SQLs have identified on Node 7 which are contributing to High disk read and CPU usage. 6) On Node 9 , CPU usage is around 25% through out the duration , No Spike has been observed , around 7 SQLs have found on Node 9 which are contributing to High Disk read and CPU usage. We are opening the PBIs for the problematic SQLs and targeting to have recommendation till Friday for Node 1, Node 2 and Node 4. Please find attached excel for the same. Thanks & Regards, ======== To check Rows proccessed select inst_id,Rows_processed,executions from gv$sqlarea where sql_id='3a51njp3dhtjd' select inst_id,Rows_processed,executions from gv$sql where sql_id='3a51njp3dhtjd' ============================================Table Rebuild SQL> @/usr/tools/oracle/Standard/onCall/core/my_sid; PID SID SERIAL# SPID ---------- ---------- ---------- ------------------------ 419 5503 57145 42850 SQL> alter table xxrpth.xxrpt_coruser move parallel 16; We see a total time remaining of 2472582 seconds , which is exceeding User's requirements , as their prod shareplex post is stopped , and they are seeing a big GG backlog . SQL> select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from v$session_longops where SID='5503'; SID SERIAL# OPNAME SOFAR TOTALWORK TIME_REMAINING ---------- ---------- ---------------------------------------------------------------- ---------- ---------- -------------- 5503 57145 Table Scan 67914 9647634 2472582 ========================================================================================================================================= https://vahidhosseini-oracledba.blogspot.com/2015/11/enq-tx-row-lock-contention.html ==== Good blogspot https://dba.cisco.com/trace/trace/authAction.do ========== Trace file INC3120619--- EPICPRD enq: TX - row lock contention: This is indicative of a session waiting for a row lock held by another session. when a session is waiting for a row level lock that is already held by another session. This occurs when one application is updating or deleting a row that another session is also trying to update or delete. This will generate a wait event "enq: TX - row lock contention". To solve this particular issue, the session holding the lock must perform a COMMIT or ROLLBACK. There are several situations of TX enqueue: In mode 6: Waits for TX in mode 6 occur when a session is waiting for a row level lock that is already held by another session. This occurs when one application is updating or deleting a row that another session is also trying to update or delete. This will generate a wait event "enq: TX - row lock contention". To solve this particular instance, the session holding the lock must perform a COMMIT or ROLLBACK. In mode 4:we have 3 reasons: 1. Unique key contention: In mode 4, a TX wait can occur if there is a potential duplicate in a unique index. When two sessions try to insert the same key value the second session must wait to see if an ORA-001 should be raised. This can cause the "enq: TX - row lock contention" wait event. This wait event can be handled by having the session holding the lock perform a COMMIT or ROLLBACK. 2. Foreign Key contention: If referential constraints have been defined between tables and the foreign key columns in the child table are not indexed, then modifications to the parent table's key cause locks on the child table, and if the foreign key columns are not indexed this can cause contention. 3. Bitmap index contention: The wait event “enq: TX – row lock contention” can also occur in mode 4 when a session is waiting on a shared bitmap index fragment. Bitmap indexes index key values and a range of ROWIDs. Each entry in a bitmap index can cover many rows in the actual table. If two sessions want to update rows covered by the same index fragment, then the second session must wait for the first session to perform either a COMMIT or a ROLLBACK by waiting for the TX lock in mode 4, otherwise it will generate the “enq: TX – row lock contention” wait event. This index is suitable for data warehouse environments. enq: HW - contention Configuration enq: SQ - contention Configuration enq: SS - contention Configuration enq: ST - contention Configuration enq: TM - contention Application enq: TW - contention Administrative enq: TX - allocate ITL entry Configuration enq: TX - index contention Concurrency enq: TX - row lock contention Application enq: TX – contention Application Step : 1 : SELECT event, p1, MOD (p1, 16) AS "mode" FROM gv$active_session_history WHERE event ='enq: TX - row lock contention'; Step : 2: select count(*) cnt, session_id sid, substr(event,1,30) event, mod(p1,16) as lm, sql_id, CURRENT_OBJ# || ' ' || object_name obj , o.object_type type , CURRENT_FILE# file# , CURRENT_BLOCK# block# , blocking_session bsid from gv$active_session_history ash, all_objects o where event like 'enq: T%' and o.object_id (+)= ash.current_obj# group by event,session_id,p1,sql_ID,CURRENT_OBJ#,OBJECT_NAME,OBJECT_TYPE,CURRENT_FILE#, CURRENT_BLOCK#, BLOCKING_SESSION order by count(*); Step :3: select substr(event,1,30) event, sql_id, CURRENT_OBJ# || ' ' || object_name obj , o.object_type type , CURRENT_FILE# file# , CURRENT_BLOCK# block# from v$active_session_history ash, ( select a.object_name, a.object_id, decode(a.object_type,'INDEX',i.index_type||' '||'INDEX',a.object_type) object_type from all_objects a, all_indexes i where a.owner=i.owner(+) and a.object_name=i.index_name(+) ) o where event like 'enq: TX%' and o.object_id (+)= ash.current_obj# order by sample_time; https://myapp.tcs.com/vpn/index.html ---------> For web mail https://cisco.service-now.com/nav_to.do ----- INC2889129 https://db-profiler.cisco.com/DBProfiler/ ---- New db profiler Tool SELECT output FROM TABLE (dbms_workload_repository.awr_report_text (DBID,instance,minsnap,maxsnap) ); SELECT output FROM TABLE (dbms_workload_repository.awr_report_html (3370857963,2,42405,42411) ); select distinct(count(session_id)) from dba_hist_active_sess_history where current_obj#=68731 and snap_id between 145438 and 145479 ============================================================================================ Sub : Pager Swap Notification for Upcoming week perf-db-ind(mailer list) <perf-db-ind@cisco.com> Manish Mantri -X (manmantr - TATA CONSULTANCY SERVICES LIMITED at Cisco) <manmantr@cisco.com> Hi Team, Madan and I will be swapping morning pager shift for upcoming week. PTO Premachand is on PTO on Today (25 Aug 2020) due to personal reasons. oracle database --- so DBA_ORACLE--- ag APPLICATION PERF MANAGEMENT ---- SO apm_DB --- ag ========================= RAOPRD: Causing Service Offering - Billing Invoice and Revenue - Non Standard Revenue (NextGen CCRM) Problem Manager AG - GSE-CVC-FIN-I2C-PBM-MGR Problem Manager - Raghu Jalapati (rjalapat) Assignment Group - GSE-CVC-FIN-I2C-NGCCRM Assigned To - Sudhakar Muppidi (sumuppid) Thanks Subrat. We will take it forward from here. Regards ============================================================================================ *************** Steps to raise acess request for Oracle support and OEM : OEM Tool Access ========================= 1. Go to https://oneaccess.cisco.com/home.jsf 2. Click on Manage User Access 3. Search for ccid eg, subpatra 4. Tick the employee Check box, then click NEXT 5. Search for EMPRD, then click on Oracle Enterprise Manager EMPRD - performance team role 6. Review and add Comments and Submit OEM Tool Link : https://emprd-op.cisco.com/em/faces/logon/core-uifwk-console-login Login with CISCO credentials. Provide only ccid. (Don't give @cisco.com) cisco login pass for OEM partcular user login : Username will be : perf11i PWD will be : dbname#123# Oracle Support Access ========================= 1. Go to https://support.oracle.com/portal/? 2. Click on View Accounts --> Oracle Account --> Create an account 3. Fill the details. Provide CISCO id. eg, Email : subpatra@cisco.com 4. Add CSI : 15403044, 14247247, 14054935 5. You'll get a confirmation mail from Oracle after few days. You'll get to know with whom the request is pending with. We can ping them seeking approvals. My Oracle account details : +++++++++++++++++++++++++++ https://support.oracle.com/portal/? user Name and Password : makancha@cisco.com Pass : Madhan@143 ++++++++++++++++++++++++++++++++++ Hi Team, Please provide the following information: 1. Is this an existing issue in production? 2. Which database? 4. Application Name? 5. What is the name of the program/ form/ report /business process that is having performance issue? 6. First Reported Time 7. Expected/Previous runtime statistics of program execution 8. Any recent changes (code/data/others)? If yes details about the changes. 9. Frequency of the program to be executed in production 10. Is the problem reproducible on a non-production environment 11. Details of a non production environment where team attempted to reproduce the problem 12. Whether tables used in the problematic sql/programs are at least 10% analyzed. 13. " LEVEL-12 TKPROF " sorted by "fchela exeela prsela" attached to the case ( Please contact DBA if required). 14. Both, a) Technical point-of-contact Onshore b) Technical point-of-contact Offshore ( for analysis and resolution support and participation for the issue) 15. Brief description of query functionality 16: Is AppDynamics enable for your application ? If YES then provide us details (application name , tires etc) ? Regards Performance Team Hi Team, please mention the SID/ Serial#, SQL ID and enable level 12 TKProf for the same and attach it to the case.... also please mention the time duration when this issue is observed along with the TZ info so that we could check the database Regards Performance Team =============================================================================================== Hi Team, Please find the attached analysis and SQL profile HI Team, Suggestion has been provided for the problematic SQL f5bg7td65tra9 related to call APPS.XXCPD_LPS_NPI_INCR_LOAD_PKG.xxcpd_status_prc(:1 ,:2 ,:3 ,:4 ) but later on as per shared session details another two SQL was coming at top, so requesting to share problematic SQL session details and TKPROF for the same to find out same, and if problematic SQL's are different please create separate case, as already created two. Apart from that for this case for f5bg7td65tra9 which was coming top SQL and after modification LIO became much less, and number of row executed also increase and from 9th onwards no plan change observed. In such a case share the problematic session while executing program and confirm us to close this case after monitoring f5bg7td65tra9 for few days. Hi Team, Kindly update below questionnaires. Hi Bramha, As checked in attached TKPROF, problematic delete statement is not captured, suggesting to perform de fragmentation and deploy sqlprofile later on generate 12-level TKPROF with proper session details for further validation. INC2512727 - mention this... if the sid/ serial# is identifiable.... please mention the SID/ Serial#, time of the issue along with TZ and enable level 12 TKProf for the same and attach it to the case.... if not, then also please mention the time duration when this issue is observed along with the TZ info so that we could check the database for that duration and identify problems if any INC2513888 - mention this... please let us know if this is a performance issue in production... if not, then, please move it to the correct SO/ AG select * from gv$version --- to check version select * from gv$parameter---- to check parametr http://vm-pefrcdn-stg-001:7070/StatementFix/InsertEntry.jsp https://cisco.service-now.com/nav_to.do?uri=%2Fhome.do%3F---- snow https://directory.cisco.com/dir/ https://dba.cisco.com/AllAboutDB ========= All about DB https://dba.cisco.com/AllAboutSQL/ =============== All abou sql Performance team is no longer providing the support for Non-PROD environments. If the teams know which SQL is causing issue they can use the DB Profiler to get the recommendations. DB Profiler: https://db-profiler.cisco.com/DBProfiler/ Please provide us the level 12 tkprof report pre and post modifications of the sql for signoff from performance end .This modifications in the sql will lead to less and constant LIO for the sql . INC2181628---> Pratik sanpshot too old error -------> INC2409675 Regarding INC2286251---can i resolve the case? marked pending for any queries on suggestions given. analysis updated, marked pending for any queries. case will be resolved after 2 reminders. reminder 1 to update if any further queries or the issue has been resolved. resolving the case as there is no followup from the user and nothing is pending from our side. Analysis updated and Resolving the case after user confirmation Hi Team, Analysis updated and Resolving the case as pending target passed Regards Madan we have cancelled this case..It's Because SLA Breached we have created new case INC2487549 instead of this current case. There is no reduction in execution count for the top SQL for this program, see attachment for details. Marked pending for any queries, 2 reminders will be given. ++++++++++++++++++++++++++++ select event,sql_id, a.* from gv$session a where username = 'WDPUB' select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id -- AND s.sid = 5756 --AND s.inst_id = 1 AND s.sql_id = '1v5tbzxag189n' AND substr(m.status,1,4) = 'EXEC' AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id ============= SELECT /*+ USE_NL(P) CARDINALITY(S 1) MONITOR*/ S.SQL_HASH_VALUE, S.PLAN_HASH, S.EVENT_TYPE, S.P1, P.CHILD_NUMBER FROM XXCPF_PM_SNAPSHOT S, XXCPF_PM_SQL_PLAN P WHERE s.plan_hash = p.plan_hash select sql_id from gv$session where sid = 761 AND inst_id = 1 select * from gv$sql where sql_id = 'acxftamk29gbr' select FETCHES, BUFFER_GETS , DISK_READS , 'SQL' from gv$sql where sql_id = '4qk105sn61usy' UNION select FETCHES, BUFFER_GETS , DISK_READS , elapsed_time from gv$sql_monitor where sid = &sid and inst_id = &inst_id UNION select FETCHES, BUFFER_GETS , DISK_READS , 'SQLAREA' from gv$sqlAREA where sql_id = '4qk105sn61usy' ********************** Query to Obtain Information on Blocking Sessions -------------------------------------- -- Query 1 -- -------------------------------------- connect sys/<password> as sysdba set linesize 500 pagesize 200 col inst_id format 99999 col sid format 99999 col spid format a6 col blocking_session_status format a6 heading 'BS' col blocking_instance format 99 heading 'BI' col blocking_session format 99999 heading 'BLKSID' col session_type format a11 col event format a31 col file_name format a21 col file_id format 9999999999999999999 col call_counter format 9999999 col wait_for_scn format 99999999999999 heading 'WAITING FOR' col wfscn format 99999999999999 heading 'WFSCN' col commit_wait_scn format 99999999999999 heading 'CWSCN' col post_commit_scn format 99999999999999 heading 'PCSCN' col clock format 99999999999999999999 heading 'CLOCK' col next_ticker format 999999999999999999999 heading 'NEXT TICKER' select wrt.inst_id, wrt.sid, wrt.serial#, wrt.spid, s.BLOCKING_SESSION_STATUS, s.BLOCKING_INSTANCE, s.blocking_session, wrt.session_type, wrt.event, wrt.file_name, wrt.file_id, wrt.call_counter, wrt.wait_for_scn, greatest(wrt.dependent_scn, wrt.statement_scn) as wfscn, wrt.commit_wait_scn, wrt.post_commit_scn, wrt.clock, wrt.next_ticker from gv$workload_replay_thread wrt, gv$session s where wrt.sid = s.sid and wrt.serial# = s.serial# order by inst_id, sid ; Query to Monitor the Approximate Progress of the Replay -------------------------------------- -- Query 2 -- -------------------------------------- set echo off connect sys/<password> as sysdba set serveroutput on DECLARE my_next_ticker NUMBER; clock NUMBER; wait_for_scn NUMBER; counts NUMBER; replay_id NUMBER; thr_failure NUMBER; start_time DATE; num_tickers NUMBER; min_scn NUMBER; max_scn NUMBER; done NUMBER; total_time INTERVAL DAY TO SECOND; CURSOR get_next_ticker(my_next_ticker NUMBER) IS SELECT spid, event, inst_id, wrc_id, client_pid FROM gv$workload_replay_thread WHERE file_id = my_next_ticker; BEGIN dbms_output.put_line('********************************'); dbms_output.put_line('* Replay Status Report *'); dbms_output.put_line('********************************'); ----------------------------------------- -- Make sure that a replay is in progress ----------------------------------------- SELECT count(*) INTO counts FROM dba_workload_replays WHERE status='IN PROGRESS'; if (counts = 0) then dbms_output.put_line('No replay in progress!'); return; end if; ------------------- -- Get replay state ------------------- SELECT id,start_time INTO replay_id, start_time FROM dba_workload_replays WHERE status='IN PROGRESS'; SELECT count(*) INTO counts FROM gv$workload_replay_thread WHERE session_type = 'REPLAY'; SELECT min(wait_for_scn), max(next_ticker), max(clock) INTO wait_for_scn, my_next_ticker, clock FROM v$workload_replay_thread WHERE wait_for_scn <> 0 AND session_type = 'REPLAY'; dbms_output.put_line('Replay has been running for: ' || to_char(systimestamp - start_time)); dbms_output.put_line('Current clock is: ' || clock); dbms_output.put_line('Replay is waiting on clock: ' || wait_for_scn); dbms_output.put_line(counts || ' threads are currently being replayed.'); ---------------------------------------- -- Find info about the next clock ticker ---------------------------------------- num_tickers := 0; for rec in get_next_ticker(my_next_ticker) loop -- We only want the next clock ticker num_tickers := num_tickers + 1; exit when num_tickers > 1; dbms_output.put_line('Next ticker is process ' || rec.spid || ' (' || rec.wrc_id || ',' || rec.client_pid || ') in instance ' || rec.inst_id || ' and is waiting on '); dbms_output.put_line(' ' || rec.event); end loop; --------------------------------------------------------------------------------------- -- Compute the replay progression and estimate the time left -- Note: This is an estimated time only, not an absolute value as it is based on SCN. --------------------------------------------------------------------------------------- SELECT min(post_commit_scn), max(post_commit_scn) INTO min_scn,max_scn FROM wrr$_replay_scn_order; done := (clock - min_scn) / (max_scn - min_scn); total_time := (systimestamp - start_time) / done; dbms_output.put_line('Estimated progression in replay: ' || to_char(100*done, '00') || '% done.'); dbms_output.put_line('Estimated time before completion: ' || ((1 - done) * total_time)); dbms_output.put_line('Estimated total time for replay: ' || total_time); dbms_output.put_line('Estimated final time for replay: ' || to_char(start_time + total_time, 'DD-MON-YY HH24:MI:SS')); END; / Query to Provide Summary of Wait Events -------------------------------------------------------------- -- Query 3 -- --------------------------------------------------------------- column event format a40 select event, count(*), min(wait_for_scn) from gv$workload_replay_thread where session_type = 'REPLAY' group by event; During replay, any error and data discrepancies between the replay system and the capture system are recorded as diverged calls. The DBMS_WORKLOAD_REPLAY.GET_DIVERGING_STATEMENT function retrieves information about a diverging call, including the statement text, the SQL ID and the binds. Example usage sqlplus / as sysdba set long 30000000 longchunksize 1000 serverout on ACCEPT ls_replay_id PROMPT 'Replay Id: ' DECLARE r CLOB; ls_stream_id NUMBER; ls_call_counter NUMBER; ls_sql_cd VARCHAR2(20); ls_sql_err VARCHAR2(512); CURSOR c IS SELECT stream_id,call_counter FROM DBA_WORKLOAD_REPLAY_DIVERGENCE WHERE replay_id = &ls_replay_id; BEGIN OPEN c; LOOP FETCH c INTO ls_stream_id, ls_call_counter; EXIT when c%notfound; DBMS_OUTPUT.PUT_LINE (ls_stream_id||''||ls_call_counter); r:=DBMS_WORKLOAD_REPLAY.GET_DIVERGING_STATEMENT(replay_id => &ls_replay_id, stream_id => ls_stream_id, call_counter => ls_call_counter); DBMS_OUTPUT.PUT_LINE (r); END LOOP; END; / Use the following for detailed set of information – Comprehensive Database Real Application Testing Diagnostic Information (Doc ID 1287620.1) ================================================= as part of LTF suggested to use index Hint passed in query and as part of STF provided sql profiles for both the problematic sql INC2222742(prem) https://shivamoraclecloud.wordpress.com/2016/05/08/enq-tx-row-lock-contention/ ---enq:tx row lock contention select * from table(dbms_xplan.display_awr('76bk7bjxkxu0y',format =>'outline')) ---- To check outline select * from table(dbms_xplan.display_cursor('76bk7bjxkxu0y',format =>'outline')) ---- To check outline DB: DMPROD Schema : XXCQO_APPS API NAME : XXCQO_APPS.XXMDM_REARCH_PKG.GET_DECOUPLE_DEAL_CONT__PR PKG : XXMDM_REARCH_PKG Procedure : GET_DECOUPLE_DEAL_CONT__PR select * from dba_objects where object_name like '%XXMDM_REARCH_PKG%' select * from dba_objects where object_id =2191580 SELECT* FROM xxcpf_pm_sqlarea WHERE sql_id='1039552910' ORDER BY TRUNC (snap_date_time) DESC Procedure body line ID# and program_id=7407758 ============================================== SELECT * FROM xxcpf_pm_sqlarea WHERE program_line# between 9399 and 11280 and program_id=7407758 ORDER BY TRUNC (snap_date_time) DESC; -------------------------------------when program name given select concurrent_program_id from apps.fnd_concurrent_programs_tl ctl where user_concurrent_program_name like '%Cisco AS Missing Timecard Notifications%'; ***************** https://dba.cisco.com/dba-portal/tools/performance-management/OTMPRD Query to Finding sql id using SQL text : ========================================= select /*+parallel(32)*/* from dba_hist_sqltext where sql_text like '%DELETE%MTL_ITEM_CATEGORIES_INTERFACE%WHERE%INVENTORY_ITEM_ID%' SELECT sql_id, hash_value, SUBSTR(sql_text,1,40) Text FROM gv$sql WHERE sql_text LIKE '%athena_flg%'; -------------------------------------------------------- To find Db links and Remote DB name select * from dba_db_links where db_link = 'RAO_TO_CG1.CISCO.COM'; select * from dba_db_links where db_link like '%XXCTS_XELUS_CTS%' --------------------------------------------------------------------------------- Blocking sessionS : ------------------ At entire database level : select sql_id , event ,current_obj#, count(*),BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# from gv$active_session_history where session_id =1699 and session_serial#=23868 group by sql_id , event,current_obj#,BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# order by 4 desc; Wait events and Blocking sessions :( for particular snap ids ) SELECT sql_id, EVENT, CURRENT_OBJ#, (SELECT object_name FROM dba_objects WHERE object_id = current_obj#) AS objectname, sql_opname, sql_plan_operation, sql_plan_options, BLOCKING_SESSION, BLOCKING_SESSION_SERIAL#, COUNT (1) FROM dba_hist_active_sess_history WHERE sql_id= '4cgt922duhyqa' and snap_id between 143218 and 143236 GROUP BY sql_id, EVENT, CURRENT_OBJ#, sql_opname, sql_plan_operation, sql_plan_options, BLOCKING_SESSION, BLOCKING_SESSION_SERIAL# ORDER BY COUNT (*) DESC ++++++++++++++++ To check snapping is enabled or not : select /*+ index(a PERF11I.XXCPF_PM_SNAPSHOT_N3)*/inst_id,max(snap_date_time) snap , sysdate from xxcpf_pm_snapshot a where snap_date_time>sysdate-12 group by inst_id; ====== Hot Block/Object : Number of concurrent session’s access single block in an object is known as hot object. RELATIVE_FNO OWNER SEGMENT_NAME SEGMENT_TYPE 94 QTCDATA CG1_RA_CUSTOMER_TRX_LINES_ALL TABLE =============== To find Hot Blocks SELECT p1 "file#", p2 "block#", p3 "class#" FROM gv$session_wait WHERE event = 'read by other session'; SELECT p1 "file#", p2 "block#", p3 "wait class#" FROM gv$session_wait WHERE event = 'gc buffer busy acquire'; SELECT relative_fno, owner, segment_name, segment_type FROM dba_extents WHERE file_id = &file AND &block BETWEEN block_id AND block_id + blocks - 1; ====================== Finding sql using object/index name SELECT p.dbid, p.sql_id, P.OBJECT_OWNER A_INDEX_OWNER, p.object_name A_INDEX_NAME, p.options A_INDEX_OPERATION, COUNT(*) NR_EXEC FROM dba_hist_sql_plan p WHERE p.object_name = '&1' GROUP BY P.dbid, P.sql_id, P.OBJECT_OWNER, p.object_name, p.options; 11g Row source at Run Time =========================== select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id AND s.sid = 4011 AND s.inst_id = 1 AND substr(m.status,1,4) = 'EXEC' AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id ************ select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id -- AND s.sid = 5756 --AND s.inst_id = 1 AND s.sql_id = 'f4rgw5jmbr745' -- AND substr(m.status,1,4) = 'EXEC' and m.sql_exec_id= 33554471 AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id select sql_exec_id from gv$sql_plan_monitor where sql_id = '52bqv2n02htrg' order by output_rows desc select * from gv$sql_plan_monitor where sql_id = '4yg4fbrdmc4z0' order by output_rows desc select sql_exec_id from gv$sql_plan_monitor where sql_id = '52bqv2n02htrg' order by output_rows desc ******************* select m.sql_id ,m.sql_plan_hash_value ,p.id, rpad(' ',p.depth*2, ' ')||p.operation ||' ' || p.options operation, p.object_name object, p.cardinality card, p.cost cost, substr(m.status,1,4) status, m.output_rows from gv$sql_plan p, gv$sql_plan_monitor m , gv$sql_monitor s where p.sql_id=m.sql_id and p.child_address=m.sql_child_address and p.plan_hash_value=m.sql_plan_hash_value and p.id=m.plan_line_id -- AND s.sid = 5756 --AND s.inst_id = 1 AND s.sql_id = '1v5tbzxag189n' AND substr(m.status,1,4) = 'EXEC' AND s.inst_id = m.inst_id AND s.inst_id = p.inst_id and s.key = m.key order by id QUERY to find sid and serial # when we have Request 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 ------------------------------------------------------------------------------------------------------------------------------------------ For I/O latency : ----------------- with base_line as ( select /*+ materialize */ snp.instance_number, snp.snap_id, to_char(snp.end_interval_time,'Mon-dd hh24:mi:ss') end_time, time_waited_micro, total_waits, event_name from dba_hist_snapshot snp, dba_hist_system_event sst where snp.dbid = :db_id and snp.instance_number = :instance_number and end_interval_time between sysdate - 15 and sysdate /* */ and sst.dbid = snp.dbid and sst.instance_number = snp.instance_number and sst.snap_id = snp.snap_id and sst.event_name = 'db file sequential read' /* */ ) select b1.instance_number, b1.snap_id , b1.end_time start_of_delta, ROUND( (b1.time_waited_micro - b2.time_waited_micro)/((b1.total_waits - b2.total_waits) *1000) , 2) value from base_line b1, base_line b2 where b2.snap_id = b1.snap_id + 1 and b2.instance_number = b1.instance_number order by b1.snap_id desc ******************* Different SQL for plan Hash Value SELECT /*+ index(q.INT$DBA_HIST_SQLSTAT.sql WRH$_SQLSTAT_INDEX) */ ---TRUNC (s.end_interval_time) sample_end, -----(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = q.plan_hash_value and hash_value!=0 and rownum=1) ||' '|| ---(SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = DBMS_UTILITY.SQLID_TO_SQLHASH (q.SQL_ID) and rownum=1) cases, q.sql_id, -- MIN (q.snap_id) min_snp, -- MAX (q.snap_id) max_snp, -- MAX (q.dbid) dbid, q.plan_hash_value phv, -- q.instance_number INST, SUM (q.EXECUTIONS_DELTA) exs, ROUND (SUM (ELAPSED_TIME_delta) / 1000 / 1000, 2) TOT_SEC, -- SUM (q.parse_calls_DELTA) hard_parse, -- SUM (q.version_count) version, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_pex, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_pex, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_pex, ROUND ( CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / GREATEST ( ROUND ( ( SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1), 1), 2) Lio_Row, ROUND ( ( SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000000), 4) IO_PEX, ROUND ( ( SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000000), 4) CPU_PEX, ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 sec_PEX --,max(s.end_interval_time) last_snap_time FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE -----q.SQL_ID = TRIM ('&sql_id') q.plan_hash_value=&plan_hash AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, --q.instance_number, TRUNC (s.end_interval_time) ORDER BY MAX (s.end_interval_time) DESC, q.sql_id, q.plan_hash_value; pass sql id as 0 and plan hash value we have sample Output : =============== SQL_ID PHV EXS TOT_SEC PIO_PEX LIO_PEX ROWS_PEX LIO_ROW IO_PEX CPU_PEX SEC_PEX 4ng4ujpkj7mnb 1058250243 1 40.12 256897 545566 21 25979.33 8.7442 32.7442 40.1231 g03ta02ft0811 1058250243 1 46.38 257010 686160 20 34308 14.629 33.741 46.3802 8uy0vz07pwrsz 1058250243 1 42.49 256940 658344 20 32917.2 12.7455 31.801 42.492 To Check Object Owner : -------> subrat ---------------------- SELECT DISTINCT object_owner, object_name ,object_owner||'.'|| object_name FROM dba_hist_sql_plan WHERE sql_id = '8ud720mw1rkyk' AND plan_hash_value =3886700095 AND object_type IN ('VIEW (FIXED)', 'TABLE (TEMP)', 'MAT_VIEW', 'TABLE (FIXED)', 'VIEW', 'TABLE'); ==========sessions and sql acting on same objects select distinct(sql_id) from dba_hist_active_sess_history where current_obj#=-40001599 and snap_id between 149383 and 149394 select distinct(sessio_id) from dba_hist_active_sess_history where current_obj#=-40001599 and snap_id between 149383 and 149394 ========= Analysis : Cause Bug 12701301 - WAIT CLASSE: OTHER OJVM : GENERIC was opened for this issue. It was closed as duplicate of : Bug 10325230 - RUNTIME.EXEC CAN HANG WHEN USED WITH RESOURCE MANAGER ACTIVE Solution Bug 10325230 will be fixed in 12.1, so currently the following options are available to solve this issue. 1. The workaround from bug 12701301: 'The issue only reproduces if resource_manager_plan ='DEFAULT_MAINTENANCE_PLAN'. If resource_manager_plan is not set, then the operation completes.' 2. The workaround from bug 10325230: 'Don't use user threads to read from Process streams, or don't use them when RM is active, or use Thread.stop or other mechanisms to actively stop/kill the threads once the related Process has exited.' 3. Apply a patch for bug 10325230. Patches can be requested only for 11.2.0.2.0 and later. Affected code did not exist before that. Just got of the phone with my buddies at oracle This is the workaround to fix the same Ideally you should not be hitting this wait as PDBPROD is currently on 19c release This issue was fixed by Oracle Bug Diagnostics group in 12.1.0.2 release Cheers 🙂 Josh Arora Friday, 11:08 PM The parameter has been set to FORCE hence the issue - Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.10.0.0.0 SQL> def DEFINE _DATE = "20-AUG-2021" (CHAR) DEFINE _CONNECT_IDENTIFIER = "PDBPROD1" (CHAR) DEFINE _USER = "PERF11I" (CHAR) DEFINE _PRIVILEGE = "" (CHAR) DEFINE _SQLPLUS_RELEASE = "1910000000" (CHAR) DEFINE _EDITOR = "vi" (CHAR) DEFINE _O_VERSION = "Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.10.0.0.0" (CHAR) DEFINE _O_RELEASE = "1910000000" (CHAR) SQL> set time on 10:34:47 SQL> set pages 50000 lines 1000 trimsp on 10:34:54 SQL> show parameter resource_manager_plan NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ resource_manager_plan string FORCE:XXCMR_APPDB_TOP_PLAN NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ resource_manager_plan string FORCE:XXCMR_APPDB_TOP_PLAN <<< There is no default value >>> for this parameter in oracle https://oracledbaarena.blogspot.com/2021/08/troubleshooting-oracle-long-running.html https://oracledbaarena.blogspot.com/2021/06/oracle-long-running-query-performance.html Step:1: when request id given to find sid SELECT a.request_id, a.status_code, a.phase_code, a.actual_start_date, a.actual_completion_date, a.completion_text, s.sid, s.serial#, s.osuser, s.process, c.spid FROM apps.fnd_concurrent_requests a, apps.fnd_concurrent_processes b, gv$process c, gv$session s WHERE a.controlling_manager = b.concurrent_process_id AND c.pid = b.oracle_process_id AND b.session_id = s.audsid AND a.request_id = &request_id ---AND a.phase_code = 'R'; Lock Query : CLEAR COLUMNS col ssid form A7 col lmode form 999 heading "loc" col request form 999 heading "req" col name form A30 break on id1 on sid select lpad(' ',decode(a.request,0,0,3))||a.sid ssid, a.id1, a.lmode, a.request, c.name from sys.obj$ c, gv$lock b, gv$lock a where a.id1 in ( select id1 from gv$lock where lmode = 0 ) and a.sid = b.sid and c.obj# = b.id1 and b.type = 'TM' order by a.id1, a.request, b.sid, c.name / Block Query : SELECT blocking_session, sid FROM v$session WHERE blocking_session != 0; select * from apps.fnd_concurrent_requests where request_id = 447652808 select * FROM apps.fnd_concurrent_requests fr WHERE fr.concurrent_program_id = 194649 AND fr.phase_code IN ( 'R') select request_id,requested_start_date, actuaL_start_date, actual_completion_date,parent_request_id ,round((actual_completion_date-actual_start_date)*24*60*60,2) time from apps.fnd_concurrent_requests where Concurrent_program_id= 194649 order by actuaL_start_date desc ; select REQUEST_ID,REQUEST_DATE,PHASE_CODE,STATUS_CODE,ACTUAL_START_DATE,ACTUAL_COMPLETION_DATE,COMPLETION_TEXT from apps.fnd_concurrent_requests where request_id = 1095666418 select * from apps.fnd_concurrent_requests where request_id in ('447652808') select * from apps.fnd_concurrent_requests where parent_request_id in ('447652808') select * from xxcpf_pm_snapshot where request_id ='472915457' order by snap_date_time desc select * from gv$sql where sql_id='5xdtmvsyzcncf'; select * from gv$sqlarea where sql_id='5xdtmvsyzcncf'; check status R/C Runing ----> SHOWING Runing -------------------------------------------- select max(snap_date_time) from xxcpf_pm_snapshot select * from xxcpf_pm_snapshot where request_id ='472915457' order by snap_date_time desc select * from xxcpf_pm_snapshot where sql_id='5xdtmvsyzcncf' order by snap_date_time desc -----1039552910 ----SQL_HASh_VALUE SELECT* FROM xxcpf_pm_sqlarea WHERE sql_hash =1039552910 ORDER BY TRUNC (snap_date_time) DESC ------2191580 PROG ID select * from dba_objects where object_id =2191580 select * from xxcpf_pm_snapshot where request_id in (452058932, 452058907) order by snap_date_time desc -----> To find sid serial # ----gv$session ----(active/inactive) ----gv$active_session_history(ash ) ----- ----Dba_active_history(awr ) ----- ************** if snapping is not enabled select sql_id, count(*), user_id,current_obj# from dba_hist_active_sess_history where sample_time >= TIMESTAMP '2020-04-01 04:40:00' AND sample_time < TIMESTAMP '2020-04-03 10:30:00' and event_id = 2952162927 group by sql_id, user_id, current_obj# order by 2 desc / ************************** select * from xxcpf_pm_snapshot where request_id in(534527861, 534527862, 534527863, 534527864, 534527865, 534527866, 534527867, 534527868, 534527869, 534527870, 534527871, 534527857, 534527858, 534527859, 534527860) order by snap_date_time desc; ------------------------------------------------------------------------------------------- TO find Dependent Sql : select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE from dba_hist_active_sess_history ash where ----ash.session_id =356--261--3784-- 1407 ---and ash.session_serial# =51384--36841-- 27977--43531 --and ash.instance_number =1--1--1--5 top_level_sql_id='724bs6hgzyahx' and sql_id<>'724bs6hgzyahx' group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc =============TO find Dependent/underlying Sql select /*+ index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*) from dba_hist_active_sess_history ash where ash.snap_id between 76892 and 76917 and dbid = (select dbid from v$database) and top_level_sql_id='a1g4r29fpwh7w' and sql_id != 'a1g4r29fpwh7w' group by ash.sql_id order by count(*) desc; ------------- To find sql acting on current object select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ session_id, session_serial#,ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE from dba_hist_active_sess_history ash where current_obj#=1417408 and snap_id between 52290 and 52293 group by session_id, session_serial#,ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 4 desc ================ finding serial # using sid select inst_id,SID,serial#,username from gv$session_longops where SID='4105'; -- select inst_id,SID,serial#,username from gv$session_longops; select * from gv$session where sid=3350 and serial#=17337 ++++++++++++++++++++++++ when particular time stamp mentioned Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from gv$active_session_history where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and '27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20; Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from dba_hist_active_sess_history where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and '27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20; Select * from (select INST_ID,SQL_ID,event WAIT_TIME,sum(time_waited) from gv$session where SAMPLE_TIME between '27-AUG_21 12:00:00 AM' and '27-AUG_21 1:00:00 AM' group by INST_ID,SQL_ID,event order by 4 desc) where rownum<20; ------- step:1: To find Top SQL select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE from dba_hist_active_sess_history ash where ash.session_id =356--261--3784-- 1407 and ash.session_serial# =51384--36841-- 27977--43531 --and ash.instance_number =1--1--1--5 --and top_level_sql_id='5xdtmvsyzcncf' group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc =============== select to_char(sql_exec_start, 'dd-Mon hh24:mi'), elapsed_time, cpu_time from gv$sql_monitor where sql_id = '2g2w2cbx5zjy8'; TO_CHAR(SQL_EXEC_START,'DD-MONHH24:MI') ELAPSED_TIME CPU_TIME 14-Sep 03:46 4399447919 431044146 =============== to find object name for snap id and sql id select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,(SELECT object_name FROM dba_objects WHERE object_id = current_obj#) AS objectname,SQL_PLAN_HASH_VALUE from dba_hist_active_sess_history ash where snap_id between 161923 and 161964 and sql_id='faukwp097vwt6' ---ash.session_id =--261--3784-- 1407 --and ash.session_serial# =--36841-- 27977--43531 --and ash.instance_number =1--1--1--5 --and top_level_sql_id='5xdtmvsyzcncf' group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc ========== select sql_id , event ,current_obj#, count(*),BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# from gv$active_session_history where session_id =802 and session_serial#=4081 group by sql_id , event,current_obj#,BLOCKING_SESSION ,BLOCKING_SESSION_SERIAL# order by 4 desc; select SID,SERIAL#,OPNAME,SOFAR,TOTALWORK,TIME_REMAINING from gv$session_longops where SID='7924'; select * from gv$session where sid= and serial#= select /*+ parallel (ash 32) index(ASH WRH$_ACTIVE_SESSION_HISTORY_PK)*/ ash.sql_id , count(*),event,current_obj#,SQL_PLAN_HASH_VALUE from dba_hist_active_sess_history ash where ash.session_id =3926--261--3784-- 1407 and ash.session_serial# =42259--36841-- 27977--43531 and ash.instance_number =1--1--1--5 --and top_level_sql_id='5xdtmvsyzcncf' group by ash.sql_id,ash.event,ash.current_obj#,SQL_PLAN_HASH_VALUE order by 2 desc -------------------------------------------------------------------------- for LOB issues SELECT * FROM DBA_LOBS WHERE OWNER = 'PXP_ADMIN' AND SEGMENT_NAME= 'SYS_LOB0066169541C00001$$' ; SELECT SUM(DBMS_LOB.GETLENGTH(CONTENT))/1024/1024/1024 SIZEGB FROM TABLE_NAME; SELECT SUM(DBMS_LOB.GETLENGTH(CONTENT))/1024/1024/1024 SIZEGB FROM TABLE_NAME; SELECT * FROM DBA_LOBS WHERE SEGMENT_NAME LIKE '%SYS_LOB0066169541C00001$$%' SELECT SEGMENT_NAME,BYTES/1024/1024/1024 SizeGB FROM DBA_SEGMENTS WHERE OWNER='PXP_ADMIN' AND SEGMENT_NAME='SYS_LOB0066169541C00001$$' ORDER BY BYTES DESC SELECT SUM(DBMS_LOB.GETLENGTH("FILE_DATA"))/1024/1024/1024 SIZEGB FROM APPS.FND_LOBS; -- SIZEGB 742.084746874869 select round(bytes/1024/1024/1024,2) SIZEGB, a.* from dba_segments a where segment_name ='' and owner ='' -- 1239.283203125 SELECT * FROM DBA_LOBS WHERE OWNER = '' AND SEGMENT_NAME= '' ; SELECT * FROM dba_EXTENTS where segment_name ='' SELECT SUM(DBMS_LOB.GETLENGTH("BE_GEO_QUAL_JSON"))/1024/1024/1024 SIZEGB FROM PXP_ADMIN.PXP_BE_GEO_QUAL_JSON_MV; BE_GEO_QUAL_JSON--- column nmae (schema.table name ) select count(*) from PXP_ADMIN.PXP_BE_GEO_QUAL_JSON_MV; COUNT(*) 136549 TO find size of LOB : ===================== select table_name, column_name, segment_name, a.bytes from dba_segments a join dba_lobs b using (owner, segment_name) where b.table_name = 'PXP_BE_GEO_QUAL_JSON_MV'; O/p as follows : TABLE_NAME COLUMN_NAME SEGMENT_NAME BYTES PXP_BE_GEO_QUAL_JSON_MV BE_GEO_QUAL_JSON SYS_LOB0066169541C00001$$ 790626304 ====================== select '''' || ash.sql_id || '''' || ',', count(*) from dba_hist_active_sess_history ash, (SELECT MAX (snap_id) max_snap_id, MIN (snap_id) min_snap_id, dbid FROM dba_hist_snapshot WHERE TRUNC (begin_interval_time) <= TO_DATE ('11-FEB-2020', 'DD-MON-YYYY') GROUP BY dbid) snap where ash.snap_id >= snap.min_snap_id and snap_id <= snap.max_snap_id and snap.dbid = ash.dbid and ash.session_id =1754 and ash.session_serial# =9365 ---and ash.instance_number = ----1 ----6 group by '''' || ash.sql_id || '''' || ',' order by 2 desc; --------------- SQL> select inst_id,sid,serial#,blocking_session,blocking_instance,sql_id,username,event,program,machine,p1,p2,last_call_et/60 from gv$session where sid=5712 and inst_id=1 ; INST_ID SID SERIAL# BLOCKING_SESSION BLOCKING_INSTANCE SQL_ID USERNAME EVENT PROGRAM MACHINE P1 P2 LAST_CALL_ET/60 ---------- ---------- ---------- ---------------- ----------------- ------------- ------------------------------ ---------------------------------------------------------------- ------------------------------------------------ ---------------------------------------------------------------- ---------- ---------- --------------- 1 5712 24074 dyj43q7nhq91z APPS db file parallel read JDBC Thin Client c7-a1-oa2-iprd-200 1 2 204.916667 +++++++++++++++++++++++++++++++++ To check Temp usage SET PAGES 999 SET LINES 300 COL USERNAME FOR A10 COL SID FOR 99999 COL PID FOR A5 COL STATUS FOR A8 COL SQL_ID FOR A13 COL EVENT FOR A30 COL CONNNECTED_FROM FOR A22 COL TABLESPACE FOR A10 COL SEGTYPE FOR A10 SELECT * FROM TEMP_USAGE WHERE STATUS='ACTIVE' AND TEMP_USED_GB>0; select sql_id,max(TEMP_SPACE_ALLOCATED)/(1024*1024*1024) gig from DBA_HIST_ACTIVE_SESS_HISTORY where sample_time > sysdate-1 and TEMP_SPACE_ALLOCATED > (50*1024*1024*1024) group by sql_id order by 2; SQL_ID GIG ------------- ---------- f8v7xup2hg4b3 68.09375 bgtyc6t6pavkm 88.3623047 d2n11pf319wg6 94.8876953 <<< Problem SQL_ID >>> =========================================================================================== SELECT a.sid, RPAD (a.opname, 30), a.sofar, a.totalwork, a.ELAPSED_SECONDS, ROUND ( ( (a.sofar) * 100) / a.totalwork, 3) "%_COMPLETED", time_remaining, RPAD (a.username, 10) username, a.SQL_HASH_VALUE, B.STATUS FROM GV$SESSION_LONGOPS a, gv$session b WHERE a.sid = &sid AND b.inst_id = &inst_id AND b.serial# = &serial AND a.sofar <> a.totalwork / Gettting SQL_TEXT if we have SQL_id(5xdtmvsyzcncf) : --------------------------------------------------- ------> click on Huge LOB DBID SQL_ID COMMAND_TYPE CON_DBID CON_ID 1,567,590,801 5xdtmvsyzcncf 2 1,567,590,801 0 Query to find SQL text : ======================== select * from DBA_HIST_SQLTEXT where sql_id='2k8z7fpqjbvdp' select * from gv$sql where sql_id='52bqv2n02htrg'; ===================== Find Long Running Sessions /************************************************************************* Check the ALL Active/Inactive session **************************************************************************/ set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' order by logon_time; /************************************************************************* Check the all Active session **************************************************************************/ set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' and b.status='ACTIVE' order by logon_time; For parallel session : ====================== col username for a12 col "QC SID" for A6 col SID for A6 col "QC/Slave" for A10 col "Requested DOP" for 9999 col "Actual DOP" for 9999 col "slave set" for A10 set pages 100 select decode(px.qcinst_id,NULL,username, ' - '||lower(substr(s.program,length(s.program)-4,4) ) ) "Username", decode(px.qcinst_id,NULL, 'QC', '(Slave)') "QC/Slave" , to_char( px.server_set) "Slave Set", to_char(s.sid) "SID", decode(px.qcinst_id, NULL ,to_char(s.sid) ,px.qcsid) "QC SID", px.req_degree "Requested DOP", px.degree "Actual DOP" from gv$px_session px, gv$session s where px.sid=s.sid (+) and px.serial#=s.serial# order by 5 , 1 desc / /************************************************************************* Check the ALL Active/Inactive sessions by machine name **************************************************************************/ set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' and b.machine='&machine' -- and b.status='ACTIVE' -- and b.status='INACTIVE' order by logon_time; /************************************************************************* Check the ALL Active/Inactive sessions by SID **************************************************************************/ set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' and b.SID='&SID' -- and b.status='ACTIVE' -- and b.status='INACTIVE' order by logon_time; /************************************************************************* Check the ALL Active/Inactive sessions by Username **************************************************************************/ set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' and b.username='&username' -- and b.status='ACTIVE' -- and b.status='INACTIVE' order by logon_time; When SQL is Running : ===================== SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME, SQL_ID, PLAN_HASH_VALUE, SUM (EXECUTIONS) EXECUTIONS, ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC, ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1) PIO_PER_EXEC, ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1) LIO_PER_EXEC, ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1) ROWS_PER_EXEC, ROUND ( (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1)) / GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1), 1), 1) lio_per_row, ROUND ( (SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'ms/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000) / GREATEST (SUM (EXECUTIONS), 1), 2) || 'sec/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000 / 60) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'min' TIME_PER_EXEC, MAX (sql_profile) sqlprofile FROM GV$SQL WHERE SQL_ID = '&sql_id' GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME) ORDER BY 1 DESC; To check History and sql proile picking or not : ================================================ SELECT s.end_interval_time sample_end, MIN (q.snap_id) min_snapid, MAX (q.snap_id) max_snapid, q.sql_id, q.plan_hash_value PHV, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, SUM (q.parse_calls_DELTA) HParse, SUM (q.version_count) vers, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_exec, ROUND ( (SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 IO_Wait, ROUND ( (SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 CPU_Wait, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / DECODE ( TRUNC(ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)), 0, 1, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)) LIO_PER_ROW, ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time, (SELECT (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE ROWNUM = 1 AND (hash_value = q.plan_hash_value OR hash_value = (SELECT DBMS_UTILITY. SQLID_TO_SQLHASH (q.sql_id) FROM DUAL))) FROM DUAL) defect_id, parsing_schema_name,max(sql_profile) FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('&sql_id') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, s.end_interval_time,parsing_schema_name ORDER BY 1 DESC, q.sql_id, q.plan_hash_value; ************* Queries to get 12C and 19 C Plans : ==================================== SELECT ( LPAD (' ', 2 * (DEPTH - 1)) || ' ' || DEPTH || ' ' || operation || ' ' || options || ' ' || object_name || ' ' || DECODE (access_predicates, NULL, NULL, 'access_predicates =' || access_predicates) || ' ' || DECODE (filter_predicates, NULL, NULL, 'filter_predicates = ' || filter_predicates) || ' ' || PARTITION_START || '-' || PARTITION_STOP || ' (Cost =' || COST || ' ' || 'Card = ' || CARDINALITY || ' Bytes =' || bytes || ')') Ex_Plan FROM (SELECT * FROM (SELECT DISTINCT operation, options, object_name, access_predicates, filter_predicates, COST, CARDINALITY, BYTES, ID, PARTITION_STOP, PARTITION_START, DEPTH, ROW_NUMBER () OVER (PARTITION BY ID ORDER BY COST DESC) rnk FROM xxcpf_pm_sql_plan WHERE plan_hash = &&plan_hash) WHERE rnk = 1) ORDER BY id; Suraj Ramchander 5/27/2022, 3:47 PM /*+ opt_param('_optimizer_cbqt_or_expansion','off')*/ Suraj Ramchander 5/27/2022, 4:14 PM SELECT snap_date_time, sql_id, plan_hash, executions, ROUND (load_duration * 24 * 60 * 60, 2) total_secs, CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1)) pio_per_exec, CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) lio_per_exec, ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1) Rows_per_exec, ROUND ( CEIL ( ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) / GREATEST ( ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1), 1), 2) LIO_PER_ROW, ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60 * 60), 2) || 'sec/' || ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60), 2) || 'min' Time_per_Exec FROM xxcpf_pm_sqlarea WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash) GROUP BY sql_id, plan_hash, executions, buffer_gets, disk_reads, executions, snap_date_time, load_duration ORDER BY snap_date_time DESC; Suraj Ramchander 5/27/2022, 4:31 PM Sent out the mail with 19c top SQLs from ASH (TS3CG1) Suraj Ramchander SELECT snap_date_time, sql_id, plan_hash, executions, ROUND (load_duration * 24 * 60 * 60, 2) total_secs, CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1)) pio_per_exec, CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) lio_per_exec, ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1) Rows_per_exec, ROUND ( CEIL ( ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) / GREATEST ( ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1), 1), 2) LIO_PER_ROW, ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60 * 60), 2) || 'sec/' || ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60), 2) || 'min' Time_per_Exec FROM xxcpf_pm_sqlarea WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash) GROUP BY sql_id, plan_hash, executions, buffer_gets, disk_reads, executions, snap_date_time, load_duration ORDER BY snap_date_time DESC; PLease use this if data is unavailable in dba_hist....and 12c executions can be checked in CG1PRD also if unavailable in TS3 Query to check whether SQL is progressing or hanged : ====================================================== column plan_line_id format 9999 heading 'LINE' column plan_options format a10 heading 'OPTIONS' column status format a10 column output_rows heading 'ROWS' break on sid on sql_id on status SELECT sid, sql_id, status, plan_line_id, plan_operation || ' ' || plan_options operation, output_rows FROM gv$sql_plan_monitor WHERE status not like '%DONE%' and sid='&sid' ORDER BY 1,4; or column plan_line_id format 9999 heading 'LINE' column plan_options format a10 heading 'OPTIONS' column status format a10 column output_rows heading 'ROWS' break on sid on sql_id on status SELECT sid, sql_id, status, plan_line_id, plan_operation || ' ' || plan_options operation, output_rows FROM v$sql_plan_monitor WHERE status not like '%DONE%' ORDER BY 1,4; SID SQL_ID STATUS LINE OPERATION ROWS ---------- ------------- ---------- ----- ------------------------- ---------- 24 5mxdwvuf9j3vp EXECUTING 0 SELECT STATEMENT 0 1 SORT AGGREGATE 0 2 NESTED LOOPS 10 3 PARTITION RANGE ALL 23794 <-- see diff 4 TABLE ACCESS FULL 23794 <-- see diff 5 TABLE ACCESS FULL 10 27 5mxdwvuf9j3vp EXECUTING 0 SELECT STATEMENT 0 1 SORT AGGREGATE 0 2 NESTED LOOPS 10 3 PARTITION RANGE ALL 23861 <--- see diff 4 TABLE ACCESS FULL 23861 <--- see diff 5 TABLE ACCESS FULL 10 12 rows selected. SQL> We can see the difference. Hence the query is not hanged ============================================ To check the Historic Plan : =========================== set lines 1000 pages 9999 COL instance_number FOR 9999 HEA 'Inst'; COL end_time HEA 'End Time'; COL plan_hash_value HEA 'Plan|Hash Value'; COL executions_total FOR 999,999 HEA 'Execs|Total'; COL rows_per_exec HEA 'Rows Per Exec'; COL et_secs_per_exec HEA 'Elap Secs|Per Exec'; COL cpu_secs_per_exec HEA 'CPU Secs|Per Exec'; COL io_secs_per_exec HEA 'IO Secs|Per Exec'; COL cl_secs_per_exec HEA 'Clus Secs|Per Exec'; COL ap_secs_per_exec HEA 'App Secs|Per Exec'; COL cc_secs_per_exec HEA 'Conc Secs|Per Exec'; COL pl_secs_per_exec HEA 'PLSQL Secs|Per Exec'; COL ja_secs_per_exec HEA 'Java Secs|Per Exec'; SELECT 'gv$dba_hist_sqlstat' source,h.instance_number, TO_CHAR(CAST(s.begin_interval_time AS DATE), 'DD-MM-YYYY HH24:MI') snap_time, TO_CHAR(CAST(s.end_interval_time AS DATE), 'DD-MM-YYYY HH24:MI') end_time, h.sql_id, h.plan_hash_value, h.executions_total, TO_CHAR(ROUND(h.rows_processed_total / h.executions_total), '999,999,999,999') rows_per_exec, TO_CHAR(ROUND(h.elapsed_time_total / h.executions_total / 1e6, 3), '999,990.000') et_secs_per_exec, TO_CHAR(ROUND(h.cpu_time_total / h.executions_total / 1e6, 3), '999,990.000') cpu_secs_per_exec, TO_CHAR(ROUND(h.iowait_total / h.executions_total / 1e6, 3), '999,990.000') io_secs_per_exec, TO_CHAR(ROUND(h.clwait_total / h.executions_total / 1e6, 3), '999,990.000') cl_secs_per_exec, TO_CHAR(ROUND(h.apwait_total / h.executions_total / 1e6, 3), '999,990.000') ap_secs_per_exec, TO_CHAR(ROUND(h.ccwait_total / h.executions_total / 1e6, 3), '999,990.000') cc_secs_per_exec, TO_CHAR(ROUND(h.plsexec_time_total / h.executions_total / 1e6, 3), '999,990.000') pl_secs_per_exec, TO_CHAR(ROUND(h.javexec_time_total / h.executions_total / 1e6, 3), '999,990.000') ja_secs_per_exec FROM dba_hist_sqlstat h, dba_hist_snapshot s WHERE h.sql_id = '&sql_id' AND h.executions_total > 0 AND s.snap_id = h.snap_id AND s.dbid = h.dbid AND s.instance_number = h.instance_number UNION ALL SELECT 'gv$sqlarea_plan_hash' source,h.inst_id, TO_CHAR(sysdate, 'DD-MM-YYYY HH24:MI') snap_time, TO_CHAR(sysdate, 'DD-MM-YYYY HH24:MI') end_time, h.sql_id, h.plan_hash_value, h.executions, TO_CHAR(ROUND(h.rows_processed / h.executions), '999,999,999,999') rows_per_exec, TO_CHAR(ROUND(h.elapsed_time / h.executions / 1e6, 3), '999,990.000') et_secs_per_exec, TO_CHAR(ROUND(h.cpu_time / h.executions / 1e6, 3), '999,990.000') cpu_secs_per_exec, TO_CHAR(ROUND(h.USER_IO_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') io_secs_per_exec, TO_CHAR(ROUND(h.CLUSTER_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') cl_secs_per_exec, TO_CHAR(ROUND(h.APPLICATION_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') ap_secs_per_exec, TO_CHAR(ROUND(h.CLUSTER_WAIT_TIME / h.executions / 1e6, 3), '999,990.000') cc_secs_per_exec, TO_CHAR(ROUND(h.PLSQL_EXEC_TIME / h.executions / 1e6, 3), '999,990.000') pl_secs_per_exec, TO_CHAR(ROUND(h.JAVA_EXEC_TIME / h.executions / 1e6, 3), '999,990.000') ja_secs_per_exec FROM gv$sqlarea_plan_hash h WHERE h.sql_id = '&sql_id' AND h.executions > 0 order by source ; Step:2: Give sql_id find plan hash value(2202985026/3268999420/2538825766/1810801894) ------- SELECT TRUNC (s.end_interval_time) sample_end, MIN (q.snap_id) min_snapid, MAX (q.snap_id) max_snapid, q.sql_id, q.plan_hash_value PHV, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, SUM (q.parse_calls_DELTA) HParse, SUM (q.version_count) vers, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_exec, ROUND ( (SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 IO_Wait, ROUND ( (SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 CPU_Wait, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / DECODE ( TRUNC(ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)), 0, 1, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)) LIO_PER_ROW, ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time, (SELECT (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE ROWNUM = 1 AND (hash_value = q.plan_hash_value OR hash_value = (SELECT DBMS_UTILITY. SQLID_TO_SQLHASH (q.sql_id) FROM DUAL))) FROM DUAL) defect_id, parsing_schema_name FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('&sql_id') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time),parsing_schema_name ORDER BY 1 DESC, q.sql_id, q.plan_hash_value; =================== Online Monitoring SET LINESIZE 2000 SET PAGESIZE 5000 COL TABLE_NAME FORMAT A30 COL NUM_ROWS FORMAT A10 SET FEEDBACK OFF col cases FORMAT a20 COL PCT_ANALYZED FORMAT A15 COL LAST_ANALYZED FORMAT A20 COL USED_BLOCKS FORMAT A15 COL BLOCKS FORMAT A15 set verify off SELECT /*+ index(q.INT$DBA_HIST_SQLSTAT.sql WRH$_SQLSTAT_INDEX) */ TRUNC (s.end_interval_time) sample_end, (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = q.plan_hash_value and hash_value!=0 and rownum=1) ||' '|| (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE hash_value = DBMS_UTILITY.SQLID_TO_SQLHASH (q.SQL_ID) and rownum=1) cases, q.sql_id, -- MIN (q.snap_id) min_snp, -- MAX (q.snap_id) max_snp, -- MAX (q.dbid) dbid, q.plan_hash_value phv, -- q.instance_number INST, SUM (q.EXECUTIONS_DELTA) exs, ROUND (SUM (ELAPSED_TIME_delta) / 1000 / 1000, 2) TOT_SEC, -- SUM (q.parse_calls_DELTA) hard_parse, -- SUM (q.version_count) version, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_pex, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_pex, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_pex, ROUND ( CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / GREATEST ( ROUND ( ( SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1), 1), 2) Lio_Row, ROUND ( ( SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000000), 4) IO_PEX, ROUND ( ( SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000000), 4) CPU_PEX, ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 sec_PEX --,max(s.end_interval_time) last_snap_time FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('&sql_id') --q.plan_hash_value=&plan_hash AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, --q.instance_number, TRUNC (s.end_interval_time) ORDER BY MAX (s.end_interval_time) DESC, q.sql_id, q.plan_hash_value; ============================================= V$sql_shared_cursor , multiple version reasons --- Reason for plan change =========================================== select sql_id,count(*) total_version,'' ||decode(max( UNBOUND_CURSOR),'Y', ' UNBOUND_CURSOR' ||'( '||SUM(DECODE( UNBOUND_CURSOR,'Y',1,0))||')' ) ||decode(max( SQL_TYPE_MISMATCH),'Y', ' SQL_TYPE_MISMATCH' ||'( '||SUM(DECODE( SQL_TYPE_MISMATCH,'Y',1,0))||')' ) ||decode(max( OPTIMIZER_MISMATCH),'Y', ' OPTIMIZER_MISMATCH' ||'( '||SUM(DECODE( OPTIMIZER_MISMATCH,'Y',1,0))||')') ||decode(max( OUTLINE_MISMATCH),'Y', ' OUTLINE_MISMATCH' ||'( '||SUM(DECODE( OUTLINE_MISMATCH,'Y',1,0))||')') ||decode(max( STATS_ROW_MISMATCH),'Y', ' STATS_ROW_MISMATCH' ||'( '||SUM(DECODE( STATS_ROW_MISMATCH,'Y',1,0))||')') ||decode(max( LITERAL_MISMATCH),'Y', ' LITERAL_MISMATCH' ||'( '||SUM(DECODE( LITERAL_MISMATCH,'Y',1,0))||')') -- ||decode(max( SEC_DEPTH_MISMATCH),'Y', ' SEC_DEPTH_MISMATCH' ||'( '||SUM(DECODE( SEC_DEPTH_MISMATCH,'Y',1,0))||'' ||decode(max( EXPLAIN_PLAN_CURSOR),'Y', ' EXPLAIN_PLAN_CURSOR' ||'( '||SUM(DECODE( EXPLAIN_PLAN_CURSOR,'Y',1,0))||')') ||decode(max( BUFFERED_DML_MISMATCH),'Y', ' BUFFERED_DML_MISMATCH' ||'( '||SUM(DECODE(BUFFERED_DML_MISMATCH,'Y',1,0))||')') ||decode(max( PDML_ENV_MISMATCH),'Y', ' PDML_ENV_MISMATCH' ||'( '||SUM(DECODE( PDML_ENV_MISMATCH,'Y',1,0))||')') ||decode(max( INST_DRTLD_MISMATCH),'Y', ' INST_DRTLD_MISMATCH' ||'( '||SUM(DECODE( INST_DRTLD_MISMATCH,'Y',1,0))||')') ||decode(max( SLAVE_QC_MISMATCH),'Y', ' SLAVE_QC_MISMATCH' ||'( '||SUM(DECODE( SLAVE_QC_MISMATCH,'Y',1,0))||')') ||decode(max( TYPECHECK_MISMATCH),'Y', ' TYPECHECK_MISMATCH' ||'( '||SUM(DECODE( TYPECHECK_MISMATCH,'Y',1,0))||')') ||decode(max( AUTH_CHECK_MISMATCH),'Y', ' AUTH_CHECK_MISMATCH' ||'( '||SUM(DECODE( AUTH_CHECK_MISMATCH,'Y',1,0))||')') ||decode(max( BIND_MISMATCH),'Y', ' BIND_MISMATCH' ||'( '||SUM(DECODE( BIND_MISMATCH,'Y',1,0))||')') ||decode(max( DESCRIBE_MISMATCH),'Y', ' DESCRIBE_MISMATCH' ||'( '||SUM(DECODE( DESCRIBE_MISMATCH,'Y',1,0))||')') ||decode(max( LANGUAGE_MISMATCH),'Y', ' LANGUAGE_MISMATCH' ||'( '||SUM(DECODE( LANGUAGE_MISMATCH,'Y',1,0))||')') ||decode(max( TRANSLATION_MISMATCH),'Y', ' TRANSLATION_MISMATCH' ||'( '||SUM(DECODE( TRANSLATION_MISMATCH,'Y',1,0))||')') --||decode(max( ROW_LEVEL_SEC_MISMATCH),'Y', ' ROW_LEVEL_SEC_MISMATCH' ||'( '||SUM(DECODE( ROW_LEVEL_SEC_MISMATCH,'Y',1,0))||'' ||decode(max( INSUFF_PRIVS),'Y', ' INSUFF_PRIVS' ||'( '||SUM(DECODE( INSUFF_PRIVS,'Y',1,0))||')') ||decode(max( INSUFF_PRIVS_REM),'Y', ' INSUFF_PRIVS_REM' ||'( '||SUM(DECODE( INSUFF_PRIVS_REM,'Y',1,0))||')') ||decode(max( REMOTE_TRANS_MISMATCH),'Y', ' REMOTE_TRANS_MISMATCH' ||'( '||SUM(DECODE(REMOTE_TRANS_MISMATCH,'Y',1,0))||')') ||decode(max( LOGMINER_SESSION_MISMATCH),'Y', ' LOGMINER_SESSION_MISMATCH' ||'( '||SUM(DECODE(LOGMINER_SESSION_MISMATCH,'Y',1,0))||')') ||decode(max( INCOMP_LTRL_MISMATCH),'Y', ' INCOMP_LTRL_MISMATCH' ||'( '||SUM(DECODE( INCOMP_LTRL_MISMATCH,'Y',1,0))||')') ||decode(max( OVERLAP_TIME_MISMATCH),'Y', ' OVERLAP_TIME_MISMATCH' ||'( '||SUM(DECODE(OVERLAP_TIME_MISMATCH,'Y',1,0))||')') --||decode(max( SQL_REDIRECT_MISMATCH),'Y', ' SQL_REDIRECT_MISMATCH' ||'( '||SUM(DECODE( SQL_REDIRECT_MISMATCH,'Y',1,0))||'' ||decode(max( MV_QUERY_GEN_MISMATCH),'Y', ' MV_QUERY_GEN_MISMATCH' ||'( '||SUM(DECODE(MV_QUERY_GEN_MISMATCH,'Y',1,0))||')') ||decode(max( USER_BIND_PEEK_MISMATCH),'Y', ' USER_BIND_PEEK_MISMATCH' ||'( '||SUM(DECODE(USER_BIND_PEEK_MISMATCH,'Y',1,0))||')') ||decode(max( TYPCHK_DEP_MISMATCH),'Y', ' TYPCHK_DEP_MISMATCH' ||'( '||SUM(DECODE( TYPCHK_DEP_MISMATCH,'Y',1,0))||')') ||decode(max( NO_TRIGGER_MISMATCH),'Y', ' NO_TRIGGER_MISMATCH' ||'( '||SUM(DECODE( NO_TRIGGER_MISMATCH,'Y',1,0))||')') ||decode(max( FLASHBACK_CURSOR),'Y', ' FLASHBACK_CURSOR' ||'( '||SUM(DECODE( FLASHBACK_CURSOR,'Y',1,0))||')') ||decode(max( ANYDATA_TRANSFORMATION),'Y', ' ANYDATA_TRANSFORMATION' ||'( '||SUM(DECODE(ANYDATA_TRANSFORMATION,'Y',1,0))||')') --||decode(max( INCOMPLETE_CURSOR),'Y', ' INCOMPLETE_CURSOR' ||'( '||SUM(DECODE( INCOMPLETE_CURSOR,'Y',1,0))||'' ||decode(max( TOP_LEVEL_RPI_CURSOR),'Y', ' TOP_LEVEL_RPI_CURSOR' ||'( '||SUM(DECODE( TOP_LEVEL_RPI_CURSOR,'Y',1,0))||')') ||decode(max( DIFFERENT_LONG_LENGTH),'Y', ' DIFFERENT_LONG_LENGTH' ||'( '||SUM(DECODE(DIFFERENT_LONG_LENGTH,'Y',1,0))||')') ||decode(max( LOGICAL_STANDBY_APPLY),'Y', ' LOGICAL_STANDBY_APPLY' ||'( '||SUM(DECODE(LOGICAL_STANDBY_APPLY,'Y',1,0))||')') ||decode(max( DIFF_CALL_DURN),'Y', ' DIFF_CALL_DURN' ||'( '||SUM(DECODE( DIFF_CALL_DURN,'Y',1,0))||')') ||decode(max( BIND_UACS_DIFF),'Y', ' BIND_UACS_DIFF' ||'( '||SUM(DECODE( BIND_UACS_DIFF,'Y',1,0))||')') ||decode(max( PLSQL_CMP_SWITCHS_DIFF),'Y', ' PLSQL_CMP_SWITCHS_DIFF' ||'( '||SUM(DECODE(PLSQL_CMP_SWITCHS_DIFF,'Y',1,0))||')') ||decode(max( CURSOR_PARTS_MISMATCH),'Y', ' CURSOR_PARTS_MISMATCH' ||'( '||SUM(DECODE(CURSOR_PARTS_MISMATCH,'Y',1,0))||')') ||decode(max( STB_OBJECT_MISMATCH),'Y', ' STB_OBJECT_MISMATCH' ||'( '||SUM(DECODE( STB_OBJECT_MISMATCH,'Y',1,0))||')') --||decode(max( ROW_SHIP_MISMATCH),'Y', ' ROW_SHIP_MISMATCH' ||'( '||SUM(DECODE( ROW_SHIP_MISMATCH,'Y',1,0))||'' ||decode(max( PQ_SLAVE_MISMATCH),'Y', ' PQ_SLAVE_MISMATCH' ||'( '||SUM(DECODE( PQ_SLAVE_MISMATCH,'Y',1,0))||')') ||decode(max( TOP_LEVEL_DDL_MISMATCH),'Y', ' TOP_LEVEL_DDL_MISMATCH' ||'( '||SUM(DECODE(TOP_LEVEL_DDL_MISMATCH,'Y',1,0))||')') ||decode(max( MULTI_PX_MISMATCH),'Y', ' MULTI_PX_MISMATCH' ||'( '||SUM(DECODE( MULTI_PX_MISMATCH,'Y',1,0))||')') ||decode(max( BIND_PEEKED_PQ_MISMATCH),'Y', ' BIND_PEEKED_PQ_MISMATCH' ||'( '||SUM(DECODE(BIND_PEEKED_PQ_MISMATCH,'Y',1,0))||')') ||decode(max( MV_REWRITE_MISMATCH),'Y', ' MV_REWRITE_MISMATCH' ||'( '||SUM(DECODE( MV_REWRITE_MISMATCH,'Y',1,0))||')') ||decode(max( ROLL_INVALID_MISMATCH),'Y', ' ROLL_INVALID_MISMATCH' ||'( '||SUM(DECODE(ROLL_INVALID_MISMATCH,'Y',1,0))||')') ||decode(max( OPTIMIZER_MODE_MISMATCH),'Y', ' OPTIMIZER_MODE_MISMATCH' ||'( '||SUM(DECODE(OPTIMIZER_MODE_MISMATCH,'Y',1,0))||')') ||decode(max( PX_MISMATCH),'Y', ' PX_MISMATCH' ||'( '||SUM(DECODE( PX_MISMATCH,'Y',1,0))||')') ||decode(max( MV_STALEOBJ_MISMATCH),'Y', ' MV_STALEOBJ_MISMATCH' ||'( '||SUM(DECODE( MV_STALEOBJ_MISMATCH,'Y',1,0))||')') ||decode(max( FLASHBACK_TABLE_MISMATCH),'Y', ' FLASHBACK_TABLE_MISMATCH' ||'( '||SUM(DECODE(FLASHBACK_TABLE_MISMATCH,'Y',1,0))||')') ||decode(max( LITREP_COMP_MISMATCH),'Y', ' LITREP_COMP_MISMATCH' ||'( '||SUM(DECODE( LITREP_COMP_MISMATCH,'Y',1,0))||')') reason from gv$sql_shared_cursor where sql_id = trim('&&sql_id') group by sql_id --------------------------------------- SELECT TRUNC (s.end_interval_time) sample_end, MIN (q.snap_id) min_snapid, MAX (q.snap_id) max_snapid, q.sql_id, q.plan_hash_value PHV, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, SUM (q.parse_calls_DELTA) HParse, SUM (q.version_count) vers, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_exec, ROUND ( (SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 IO_Wait, ROUND ( (SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 CPU_Wait, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / DECODE ( TRUNC(ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)), 0, 1, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)) LIO_PER_ROW, ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time, (SELECT (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE ROWNUM = 1 AND (hash_value = q.plan_hash_value OR hash_value = (SELECT DBMS_UTILITY. SQLID_TO_SQLHASH (q.sql_id) FROM DUAL))) FROM DUAL) defect_id FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('875vxcp579422') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time) ORDER BY 1 DESC, q.sql_id, q.plan_hash_value; ------------- if table or view does not exist for above query SELECT TRUNC (s.end_interval_time) sample_end, MIN (q.snap_id) min_snapid, MAX (q.snap_id) max_snapid, q.sql_id, q.plan_hash_value PHV, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, SUM (q.parse_calls_DELTA) HParse, SUM (q.version_count) vers, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_exec, ROUND ( (SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 IO_Wait, ROUND ( (SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 CPU_Wait, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / DECODE ( TRUNC(ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)), 0, 1, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)) LIO_PER_ROW, ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('cx0spupaccgpd') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time) ORDER BY 1 DESC, q.sql_id, q.plan_hash_value; -------------------------------------------------------------------------------------------------- Step:3: click F5(script execute) and pass plan hash value(2202985026) SET LINESIZE 2000 SET PAGESIZE 5000 COL TABLE_NAME FORMAT A30 COL NUM_ROWS FORMAT A10 SET FEEDBACK OFF COL PCT_ANALYZED FORMAT A15 COL LAST_ANALYZED FORMAT A20 COL USED_BLOCKS FORMAT A15 COL BLOCKS FORMAT A15 def plan_hash = &&plan_hash_value set verify off SELECT (lpad(' ',2*(depth-1)) ||' '||depth||' '||operation || ' ' || options || ' ' ||object_name||' '|| decode(access_predicates , null , null , 'access_predicates =' || access_predicates) || ' ' || decode( filter_predicates , null , null , 'filter_predicates = ' || filter_predicates ) || ' ' || PARTITION_START||'-'||PARTITION_STOP||' (Cost ='||COST||' '||'Card = '||Cardinality||' Bytes ='||bytes||')' ) Ex_Plan FROM ( SELECT DISTINCT operation , options , object_name , access_predicates , filter_predicates, COST , CARDINALITY , BYTES, ID , PARTITION_STOP , PARTITION_START,DEPTH FROM xxcpf_pm_sql_plan WHERE plan_hash= &&plan_hash ) --and CHILD_NUMBER = 0 ORDER BY id; SELECT table_name, CEIL (num_rows) num_rows, ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows), 2 ) pct_analyzed, last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks, blocks, DECODE (num_rows, 0, 0, ((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100 ) / blocks ) fragmentation, ( select stale_stats from dba_tab_statistics a where a.table_name = table_name and rownum=1) as isstale FROM all_tables A WHERE (owner, table_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash UNION ALL SELECT table_owner, table_name FROM all_indexes WHERE (owner, index_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash)) ORDER BY num_rows DESC / SET LINESIZE 2000 COL TABLE_NAME FORMAT A30 COL NUM_ROWS FORMAT A10 COL PCT_ANALYZED FORMAT A15 COL LAST_ANALYZED FORMAT A20 COL USED_BLOCKS FORMAT A15 COL BLOCKS FORMAT A15 SELECT table_name, partition_name , CEIL (num_rows) num_rows, ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows), 2 ) pct_analyzed, last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks, blocks, DECODE (num_rows, 0, 0, ((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100 ) / blocks ) fragmentation FROM dba_tab_partitions WHERE (table_owner, table_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash UNION ALL SELECT table_owner, table_name FROM all_indexes WHERE (owner, index_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash)) ORDER BY num_rows DESC / set linesize 2000 set pagesize 50000 col table_name format a30 col index_name format a30 col column_name format a30 col COLUMN_POSITION format a15 col blevel format a6 col leaf_blocks format a6 col num_rows format a15 col pct_analyzed format a15 col last_analyzed format a20 col clustering_factor format a20 col uniqueness format a20 SELECT i.table_name, i.status, i.index_name, c.column_name, c.column_position, i.blevel, i.leaf_blocks, CEIL (i.num_rows) num_rows, DECODE (i.num_rows, 0, 0, ROUND (i.sample_size * 100 / i.num_rows, 2) ) pct_analyzed, i.last_analyzed, i.clustering_factor, i.uniqueness FROM all_indexes i, all_ind_columns c WHERE (i.owner, i.index_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash) AND i.index_name = c.index_name AND i.table_owner = c.table_owner AND i.table_name = c.table_name ORDER BY 1, 3, 5 / set pagesize 5000 set linesize 2000 col table_name format a30 col column_name format a30 col num_nulls format a10 col num_distinct format a10 col density format a10 SELECT table_name, column_name, num_nulls, num_distinct, density, histogram FROM all_tab_cols WHERE (owner, table_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash UNION ALL SELECT table_owner, table_name FROM all_indexes WHERE (owner, index_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash)) AND EXISTS ( SELECT * FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash AND INSTR (access_predicates || ' ' || filter_predicates, column_name ) > 0) ORDER BY 1, 2 / ==============AWR SELECT output FROM TABLE (dbms_workload_repository.awr_report_html (1132959846,2,28820,28821) ); ---(DBID inst ID begin end snap) SELECT output FROM TABLE( DBMS_WORKLOAD_REPOSITORY.ASH_REPORT_TEXT( 1557521192, 1, 5390, 5392) ) ; ----------or (DBID inst ID begin end snap) SELECT /*+parallel(8)*/ sql_id, COUNT(*), event FROM gv$active_session_history WHERE sample_time BETWEEN TO_DATE('16-mar-2022 22:40:29', 'DD-Mon-YYYY HH24:MI:SS') AND TO_DATE('16-mar-2022 22:53:05', 'DD-Mon-YYYY HH24:MI:SS') AND upper(module) LIKE '%WINNERS_BATCH%' AND sql_id = '4cb3ufq8126jb' GROUP BY sql_id, event ORDER BY COUNT(1) DESC; Step:3: pass pHv (206559214) select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ALL')); select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ADVANCED')); === select * from table(dbms_xplan.display_awr('6z6a9y4mz2z1w', format => 'ADVANCED +REMOTE')) select * from table(dbms_xplan.display_awr ('dwh6crb9kv06n', format => 'ADVANCED +REMOTE +PEEKED_BINDS +outline +iostats +ALLSTATS LAST')) select * from table(dbms_xplan.display_awr('76bk7bjxkxu0y',format =>'outline')) ************ To check Histogram Stats on Table : SELECT COLUMN_NAME, NOTES, HISTOGRAM FROM USER_TAB_COL_STATISTICS WHERE TABLE_NAME = 'XXCP_VT_INTERFACE'; ============== SQL> SELECT * FROM TABLE(DBMS_XPLAN.display_cursor(sql_id=>'9ux2cxrxq8dp3', format=>'ALLSTATS LAST +cost +bytes')); SELECT* FROM dba_hist_sql_plan WHERE sql_id='81f9vxmvjudw8' SELECT* FROM xxcpf_pm_sql_plan WHERE sql_id='81f9vxmvjudw8' SELECT* FROM gv$sql_plan WHERE sql_id='81f9vxmvjudw8' dbms_xplan.display_awr/ DBMS_XPLAN.display_cursor gv$sql_plan dba_hist_sql_plan xxcpf_pm_sql_plan GV$SQL_PLAN select * from GV$SQL_PLAN_MONITOR WHERE SQL_ID='d00zztwfbq25f' ------------------------------------ ************* if query is Running : SELECT inst_id,sql_id, plan_hash_value, disk_reads, buffer_gets, rows_processed, executions, (elapsed_time / 1000 / 1000) elapsed_time,sql_profile FROM gv$sql WHERE sql_id IN ('0z4kcp38wypn5') To raise a case : Please reach out to DBA through Click to Spark. Below is the url and select Impacted service offering : oracle database Available DBA will assist you further. https://clicktospark.cloudapps.cisco.com/home For Creating a Case with DBA Team. https://cisco.service-now.com Select Impacted service offering as : Oracle database ***************** select owner,table_name,num_rows,last_analyzed,stale_stats from DBA_TAB_STATISTICS where table_name='DLP_SYSTEM_ITEMS' Table Stats : ------------ SELECT table_name, CEIL (num_rows) num_rows, ROUND (DECODE (num_rows, 0, 0, sample_size * 100 / num_rows), 2 ) pct_analyzed, last_analyzed, CEIL (avg_row_len * num_rows / 8192) used_blocks, blocks, DECODE (num_rows, 0, 0, ((blocks - CEIL (avg_row_len * num_rows / 8192)) * 100 ) / blocks ) fragmentation, ( SELECT STALE_STATS FROM DBA_TAB_STATISTICS D WHERE D.TABLE_NAME= A.TABLE_NAME AND A.OWNER = D.OWNER and object_type = 'TABLE') STALE FROM all_tables A WHERE (owner, table_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash_value UNION ALL SELECT table_owner, table_name FROM all_indexes WHERE (owner, index_name) IN ( SELECT object_owner, object_name FROM xxcpf_pm_sql_plan a WHERE plan_hash= &&plan_hash_value)) ORDER BY num_rows DESC To check stale stats using SQL ID : =================================== select distinct owner, table_name, STALE_STATS, last_analyzed, stattype_locked from dba_tab_statistics where (owner, table_name) in (select distinct owner, table_name from dba_tables where ( table_name) in ( select object_name from gv$sql_plan where upper(sql_id) = upper('&sql_id') and object_name is not null)) --and STALE_STATS='YES' Script for index stats : ------------------------ select * from dba_ind_statistics where table_name='' and stale_stats='YES';(No stats showing) To find schema using sql id : ----------------------------- select * from gv$session where sid='1139' -----> schema name SYS Top CPU Consuming Session in last 10 min : =========================================== select * from ( select session_id, session_serial#, count(*) from v$active_session_history where session_state= 'ON CPU' and sample_time >= sysdate - interval '10' minute group by session_id, session_serial# order by count(*) desc ); To know details from gv$sql : ---------------------------- SELECT* FROM gv$sql WHERE sql_id='5uhjrjypmzrgv' TO check Bind peeking :(https://learningoracledba.wordpress.com/2018/02/23/child-cursor-bind-peeking-roll_invalid_mismatch/) ======================== The Sql text has many bind variables, Sometimes Oracles goes for adaptive cursor sharing to peek the bind variables and avoids bad plans. How can we check if we have any bind peeking in our case We can see the Bind aware is No , So we don’t have any bind peeking happening here SELECT sql_id, child_number, is_bind_sensitive, is_bind_aware FROM gv$sql WHERE SQL_ID='7crqdmwxugnrb'; SQL_ID CHILD_NUMBER IS_BIND_SENSITIVE IS_BIND_AWARE 7crqdmwxugnrb 0 Y N 7crqdmwxugnrb 0 Y N 7crqdmwxugnrb 1 Y N 7crqdmwxugnrb 2 Y N 7crqdmwxugnrb 0 Y N 7crqdmwxugnrb 0 Y N Query to check SQL profile picking or not : ========================================== SELECT inst_id, sql_id, EXECUTIONS, PLAN_HASH_VALUE, CEIL (ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1)) pio_exec, CEIL (ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1)) lio_exec, ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1) Rows_exec, ROUND ( ( ROUND ( ( SUM (ELAPSED_TIME) / GREATEST (SUM (EXECUTIONS), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( ( ROUND ( ( SUM (ELAPSED_TIME) / GREATEST (SUM (EXECUTIONS), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time, SQL_profile FROM gv$sqlarea WHERE sql_id = 'art0f01ftyq9b' --and inst_id=3 GROUP BY inst_id, sql_id, EXECUTIONS, PLAN_HASH_VALUE,SQL_profile; QUERY S TO KNOW FROM WHICH PACKAGE IT IS CALLING : -------------------------------------------------- select * from xxcpf_pm_snapshot where sql_id='5xdtmvsyzcncf' order by snap_date_time desc -----1039552910 ----SQL_HASh_VALUE SELECT* FROM xxcpf_pm_sqlarea WHERE sql_hash =1039552910 ORDER BY TRUNC (snap_date_time) DESC ------2191580 PROG ID select * from dba_objects where object_id =2191580(PROG_ID) -----XXDH_ATS_OUTBOUND_PKG ----> obj ----PACKAGE BODY ------> obj type WFPUBLISH XXDH_ATS_OUTBOUND_PKG 2191580 PACKAGE BODY 1/16/2017 6:30:10 AM 7/29/2019 7:44:10 AM 2019-07-29:07:44:10 VALID N N N 2 NONE Y N -----XXDH_ATS_OUTBOUND_PKG ---> f4 ----> tOggle WFPUBLISH."XXDH_ATS_OUTBOUND_PKG" ------> pkg body call WFPUBLISH ------> owner /schema -----For Distinct Values---- select /*+parallel(32)*/RUN_STATUS,count(*) from WFPUBLISH.XXDH_OUTBOUND_REQUESTS group by RUN_STATUS order by 2 desc ============================= select /*+parallel(8)*/ count(*), SOURCE,ORDER_TYPE,PROCESS_FLAG from XXCTS_O.XXCTS_PLAN_ORDER_STAGING group by SOURCE,ORDER_TYPE,PROCESS_FLAG order by 2 desc Select INST_ID,name,datatype_string,value_string from gv$sql_bind_capture where sql_id = 'frv6z0mjuckw9'; SQL> select index_name,index_type,owner,status from dba_indexes where table_name='XXGCO_RPT_GENERIC_NEW_TEMP'; INDEX_NAME INDEX_TYPE OWNER STATUS XXGCO_RPT_GENERIC_NEW_TEMP_N1 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N2 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N3 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N4 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N5 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N6 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N7 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N8 NORMAL XXGCO UNUSABLE XXGCO_RPT_GENERIC_NEW_TEMP_N9 NORMAL XXGCO UNUSABLE 9 rows selected. ----bind variables-------- select name,datatype_string,value_string,count(*) from dba_hist_Sqlbind where sql_id ='&sql_id' group by name,datatype_string,value_string order by 4 desc; ============== select * from dba_db_links where db_link like '%XXCTS_XELUS_CTS%' remote DB is VISPROD ============ select name , value_string, datatype_string ,last_captured,was_captured , count(*) from dba_hist_sqlbind where sql_id = '7aqj16gxkauc0' group by name , value_string, datatype_string ,last_captured,was_captured order by 4 desc; SELECT TO_CHAR (last_captured, 'dd-Mon-yy hh24:mi:ss AM') last_captured, name bind, value_string VALUE_STR, datatype_string data_type FROM gv$sql_bind_capture WHERE sql_id = '&sql_id' AND was_captured = 'YES' gv$bincapture -----5xdtmvsyzcncf ----> showing nothing(No bind variables present in sql_text) ************* VVIMP Query :::::: select h.* from dba_hist_active_sess_history h where 1=1 --and session_id=5571 --and h.session_serial#=64445 and h.sample_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS') and h.instance_number=9 --and h.session_state='ON CPU' and h.sql_id='bmngs1g8p1wu8' order by sample_time ; select s.* from dba_hist_Sqlstat s,dba_hist_snapshot n where s.instance_number=9 and 1=1 and s.snap_id=n.snap_id and s.instance_number=n.instance_number --and s.executions_delta>0 --and s.instance_number in(5,8) and s.sql_id='bmngs1g8p1wu8' --and round((sum(s.physical_read_bytes_delta)/1024/1024)/sum(s.executions_delta),2)>100 and n.begin_interval_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS') order by s.snap_id;select h.* from dba_hist_active_sess_history h where 1=1 --and session_id=5571 --and h.session_serial#=64445 and h.sample_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS') and h.instance_number=9 --and h.session_state='ON CPU' and h.sql_id='bmngs1g8p1wu8' order by sample_time ; select s.* from dba_hist_Sqlstat s,dba_hist_snapshot n where s.instance_number=9 and 1=1 and s.snap_id=n.snap_id and s.instance_number=n.instance_number --and s.executions_delta>0 --and s.instance_number in(5,8) and s.sql_id='bmngs1g8p1wu8' --and round((sum(s.physical_read_bytes_delta)/1024/1024)/sum(s.executions_delta),2)>100 and n.begin_interval_time between to_timestamp('30-Apr-2022 07:00:00','DD-MON-YYYY HH24:MI:SS') and to_timestamp('30-Apr-2022 09:30:00','DD-MON-YYYY HH24:MI:SS') order by s.snap_id; =================================Statement FIX INSERT INTO xxcpf_pm_sql_statement_fix (hash_value, REFERENCE, sql_id, creation_date, update_date, hash_type, gbp, paged, case_type, module) VALUES (2749603398, 'PRB0062786', 'gu9fhks50cwm8', SYSDATE, SYSDATE, 'Plan_Hash', NULL, 'N', 'P', NULL); commit ******* SQLs from dba_hist_active_sess_history :- SELECT /*+ parallel */ q.sql_id, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, ROUND ( ( ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( ( ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE parsing_schema_name LIKE '%QBLRO%' AND q.SQL_ID IN (SELECT DISTINCT sql_id FROM dba_hist_active_sess_history WHERE module LIKE '%JDBC%') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id SQLs from xxcpf_pm_sqlarea :- SELECT sql_id, MAX (executions) execs, ROUND (MAX (load_duration) * 24 * 60 * 60, 2) total_sec, ROUND ( ( (MAX (load_duration) / GREATEST (MAX (executions), 1)) * 24 * 60 * 60), 2) || 'sec/' || ROUND ( ( (MAX (load_duration) / GREATEST (MAX (executions), 1)) * 24 * 60), 2) || 'min' Time_per_Exec FROM xxcpf_pm_sqlarea WHERE sql_id IN (SELECT DISTINCT sql_id FROM xxcpf_pm_snapshot WHERE module LIKE '%JDBC%' AND schema LIKE '%QBLRO%') GROUP BY sql_id; ************* SELECT snap_date_time, sql_id, plan_hash, executions, ROUND (load_duration * 24 * 60 * 60, 2) total_secs, CEIL (ROUND (SUM (disk_reads) / GREATEST (SUM (executions), 1), 1)) pio_per_exec, CEIL (ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) lio_per_exec, ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1) Rows_per_exec, ROUND ( CEIL ( ROUND (SUM (buffer_gets) / GREATEST (SUM (executions), 1), 1)) / GREATEST ( ROUND ( (SUM (rows_processed) / GREATEST (SUM (executions), 1)), 1), 1), 2) LIO_PER_ROW, ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60 * 60), 2) || 'sec/' || ROUND ( ( (load_duration / GREATEST (SUM (executions), 1)) * 24 * 60), 2) || 'min' Time_per_Exec FROM xxcpf_pm_sqlarea WHERE sql_id IN (TRIM ('&sql_id')) --or plan_hash in (:plan_hash) GROUP BY sql_id, plan_hash, executions, buffer_gets, disk_reads, executions, snap_date_time, load_duration ORDER BY snap_date_time DESC; ******* INSERT INTO xxcpf_pm_sql_statement_fix (REFERENCE, HASHTYPE, HASHVALUE, CREATED_BY, SQL_ID, FIRST_ASSIGNED_DATE, GBP, RELEASE_TD, PAGED, CASE_TYPE, MODULE, ANALYST_NAME, DB_NAME, ENVIRONMENT_TYPE, REQUEST_TYPE, CASE_PRIORITY, PROBLEM_TYPE, CASE_STATUS, CASE_RECOMMENDATION, QUARTER_DETAIL, CASE_REQUESTOR, CASE_REQUESTOR_MANAGER, WEEK_NUMBER, CONC_PROG_ID) VALUES ('INC7408576', 'Plan Hash', 313127912, 'aditytha', 'f4rgw5jmbr745', SYSDATE, NULL, NULL, NULL, 'Reactive', 'JDBC Thin Client', 'Aditya Thakur', 'OTMPRD', 'PRODUCTION', 'INC', 'P5', 'Code Design-Query Rewrite', 'Analysis Updated', 'Query Re-write', 'Q4FY22', 'macanton', 'mzakki', 1, NULL); ************* Stesp to enable 10053/10046 Trace : alter session set tracefile_identifier='case3fixcontrols'; alter session set timed_statistics = true; alter session set statistics_level= 'all'; alter session set max_dump_file_size = unlimited; alter session set "_fix_control"='13831671:0'; alter session set "_fix_control"='12555499:0'; alter session set "_fix_control"='26527656:0'; alter session set events '10053 trace name context forever, level 12'; SELECT XPSA.PART_NUMBER PART_NUMBER, XPSA.LOCATION LOCATION, XPSA.LAST_UPDATE_DATE STK_LAST_UPDATE_DATE, XPSA.CREATION_DATE STK_CREATION_DATE, XPSA.REPAIR_WIP_QTY REPAIR_WIP_QTY, XPSA.ACT_OHB_QTY ACT_OHB_QTY, XPSA.REPAIR_BAD_QTY REPAIR_BAD_QTY, XPSA.RETURN_BAD_QTY RETURN_BAD_QTY, XPSA.RPRXDOC_QTY RPRXDOC_QTY, XPSA.REPAIR_STOCK_QTY REPAIR_STOCK_QTY, XPSA.RPRNNET_QTY RPRNNET_QTY, XPSA.REPAIR_FGI_QTY REPAIR_FGI_QTY, XPSA.REPAIR_WIP2_QTY REPAIR_WIP2_QTY, XPSA.REPAIR_INTR_QTY REPAIR_INTR_QTY, XPSA.AMOUNTCUSTOM7 AMOUNTCUSTOM7, XPSA.AMOUNTCUSTOM8 AMOUNTCUSTOM8, XPSA.AMOUNTCUSTOM9 AMOUNTCUSTOM9, RPR_O_QTY.OPEN_QUANTITY REPAIR_OPEN_QTY, NULL LOC_PRIORITY, SYSDATE CREATION_DATE, :B2 CREATED_BY, SYSDATE LAST_UPDATE_DATE, :B2 LAST_UPDATED_BY, :B1 LAST_UPDATE_LOGIN, NULL REPAIR_WASHRATE, NULL PREV_PRIORITY_LOC FROM C2S_STOCK_AMOUNT_V_test XPSA, ( SELECT XPOD.SHIP_FROM_ORG_CODE, XPOD.ORDERED_PART, SUM ( (CASE WHEN XPOD.OE_LINE_ID IS NOT NULL THEN ( NVL (XPOD.ORDERED_QUANTITY, 0) - NVL (XPOD.SHIPPED_QUANTITY, 0)) ELSE ( NVL (XPOD.REPAIR_QUANTITY, 0) - NVL (XPOD.REPAIR_CANCELLED_QUANTITY, 0)) END)) OPEN_QUANTITY FROM APPS.XXCTS_PLAN_PDL_ORDER_DATA XPOD WHERE XPOD.ORDER_TYPE = 'INTERNAL-REPAIR' GROUP BY XPOD.SHIP_FROM_ORG_CODE, XPOD.ORDERED_PART) RPR_O_QTY WHERE 1 = 1 AND XPSA.LOCATION = RPR_O_QTY.SHIP_FROM_ORG_CODE(+) AND XPSA.PART_NUMBER = RPR_O_QTY.ORDERED_PART(+); alter session set events '10053 trace name context off'; ************* /* Formatted on 03/12/2021 11:35:12 (QP5 v5.294) */ DECLARE l_ph NUMBER := 159833193; l_ref VARCHAR2 (50) := 'PRB0077471'; l_sql_id VARCHAR2 (50) := 'g7fhts92rapsj'; l_module VARCHAR2 (100) := 'SQL*Plus'; l_conc_prog_id NUMBER := NULL; l_qe VARCHAR2 (50) := NULL; l_rel VARCHAR2 (50) := NULL; BEGIN BEGIN INSERT INTO xxcpf_pm_sql_statement_fix (hash_value, REFERENCE, sql_id, creation_date, update_date, hash_type, gbp, paged, case_type, module, CONCURRENT_PROGRAM_ID) VALUES (DBMS_UTILITY.SQLID_TO_SQLHASH (l_sql_id), l_ref, l_sql_id, SYSDATE, SYSDATE, 'SQL_Hash', NULL, 'N', 'P', l_module, l_conc_prog_id); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('SQL Hash already exists'); END; BEGIN IF l_ph != 0 THEN INSERT INTO xxcpf_pm_sql_statement_fix (hash_value, REFERENCE, sql_id, creation_date, update_date, hash_type, gbp, paged, case_type, module, CONCURRENT_PROGRAM_ID) VALUES (l_ph, l_ref, l_sql_id, SYSDATE, SYSDATE, 'Plan_Hash', NULL, 'N', 'P', l_module, l_conc_prog_id); END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('Plan Hash already exists'); END; IF SQL%FOUND THEN DBMS_OUTPUT.put_line ('Something was inserted'); COMMIT; END IF; END; /* QE Issues DECLARE l_ph NUMBER := 3879424810; l_ref VARCHAR2 (50) := 'PRB00602214'; l_sql_id VARCHAR2 (50) := '433us6nv8j3fq'; l_module VARCHAR2 (100) := 'JDBC Thin Client'; l_conc_prog_id NUMBER := null; l_qe VARCHAR2 (50) := 'Q2FY21'; l_rel VARCHAR2 (50) := null; BEGIN BEGIN INSERT INTO xxcpf_pm_sql_statement_fix (hash_value, REFERENCE, sql_id, creation_date, update_date, hash_type, gbp, paged, case_type, module, CONCURRENT_PROGRAM_ID, QE_RELATED, RELEASE_TD) VALUES (DBMS_UTILITY.SQLID_TO_SQLHASH (l_sql_id), l_ref, l_sql_id, SYSDATE, SYSDATE, 'SQL_Hash', NULL, 'N', 'P', l_module, l_conc_prog_id, l_qe, l_rel); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('SQL Hash already exists'); END; BEGIN IF l_ph != 0 THEN INSERT INTO xxcpf_pm_sql_statement_fix (hash_value, REFERENCE, sql_id, creation_date, update_date, hash_type, gbp, paged, case_type, module, CONCURRENT_PROGRAM_ID, QE_RELATED, RELEASE_TD) VALUES (l_ph, l_ref, l_sql_id, SYSDATE, SYSDATE, 'Plan_Hash', NULL, 'N', 'P', l_module, l_conc_prog_id, l_qe, l_rel); END IF; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ('Plan Hash already exists'); END; IF SQL%FOUND THEN DBMS_OUTPUT.put_line ('Something was inserted'); COMMIT; END IF; END; */ ************ this is the query for inserting the details in statement fix table To check statement fix entry : select * from xxcpf_pm_sql_statement_fix where REFERENCE='PRB0065646' select * from xxcpf_pm_sql_statement_fix where sql_id='d19qvv2n7dwwc' select * from gv$sqlarea where sql_id='dxm217x42hhfc' ================================================================================== ---------------Parsing schema SELECT TRUNC (s.end_interval_time) sample_end, MIN (q.snap_id) min_snapid, MAX (q.snap_id) max_snapid, q.sql_id, q.plan_hash_value PHV, SUM (q.EXECUTIONS_DELTA) exec, SUM (ELAPSED_TIME_delta) / 1000 / 1000 SEC_Total, SUM (q.parse_calls_DELTA) HParse, SUM (q.version_count) vers, CEIL ( ROUND ( SUM (DISK_READS_delta) / GREATEST (SUM (executions_delta), 1), 1)) pio_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) lio_exec, ROUND ( (SUM (IOWAIT_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 IO_Wait, ROUND ( (SUM (CPU_TIME_DELTA) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000 CPU_Wait, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1) Rows_exec, CEIL ( ROUND ( SUM (BUFFER_GETS_delta) / GREATEST (SUM (executions_delta), 1), 1)) / DECODE ( TRUNC(ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)), 0, 1, ROUND ( (SUM (rows_processed_delta) / GREATEST (SUM (executions_delta), 1)), 1)) LIO_PER_ROW, ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / 1000), 4) || 'S/' || ROUND ( (ROUND ( ( SUM (ELAPSED_TIME_delta) / GREATEST (SUM (executions_delta), 1) / 1000), 1) / (1000 * 60)), 4) || 'M' exec_time, (SELECT (SELECT reference FROM xxcpf_pm_sql_statement_fix WHERE ROWNUM = 1 AND (hash_value = q.plan_hash_value OR hash_value = (SELECT DBMS_UTILITY. SQLID_TO_SQLHASH (q.sql_id) FROM DUAL))) FROM DUAL) defect_id, parsing_schema_name FROM dba_hist_sqlstat q, dba_hist_snapshot s WHERE q.SQL_ID = TRIM ('&sql_id') AND s.snap_id = q.snap_id AND s.dbid = q.dbid AND s.instance_number = q.instance_number GROUP BY q.sql_id, q.plan_hash_value, TRUNC (s.end_interval_time),parsing_schema_name ORDER BY 1 DESC, q.sql_id, q.plan_hash_value; Observations : 1. we could see Plan fluctuation for the SQL 2. SQL is going with sub Optimal Plan 3. We could see the Top wait event is db file sequential read 4. SQL is getting called from the package XXCTS_RPR_ECO_INVOICE_CRT_PKG (PACKAGE BODY call)( PROG ID 142545034 Prog Line #1146) 5. showing index stats as stale and PCT Analyzed is not 100% analyzed. 6. We could see increase in number of executions and Load Kindly check if any additional joining condition/filter could be added to the query. If not, then the query is already optimal. RECOMMENDATION: 1. Please gather the stats on the tables and indexes with 100% with no_invalidate=> false option . 2. AS Part of LTF/Fix Please use below modified query SELECT /*+ leading(MSB) use_nl (MSB MMT) */ COUNT (MMT.TRANSACTION_ID) REC_COUNT FROM MTL_MATERIAL_TRANSACTIONS MMT, MTL_UNIT_TRANSACTIONS MUT, MTL_SYSTEM_ITEMS_B MSB WHERE MMT.TRANSACTION_ID = MUT.TRANSACTION_ID AND MMT.INVENTORY_ITEM_ID = MUT.INVENTORY_ITEM_ID AND MMT.ORGANIZATION_ID = MUT.ORGANIZATION_ID AND MSB.INVENTORY_ITEM_ID = MMT.INVENTORY_ITEM_ID AND MSB.ORGANIZATION_ID = XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID () AND MMT.SHIPMENT_NUMBER IS NOT NULL AND MSB.SEGMENT1 = UPPER ( :B4) AND UPPER (MUT.SERIAL_NUMBER) = UPPER ( :B3) AND MMT.ORGANIZATION_ID = :B2 AND MMT.TRANSACTION_DATE >= :B1 AND ( MSB.ENABLED_FLAG = 'Y' OR SYSDATE BETWEEN MSB.START_DATE_ACTIVE AND MSB.END_DATE_ACTIVE) 3. Please test/implement it in lower environment First and then in Prod also provide us Pre and Post level 12 Tkprof to validate the performance gain for the same RECOMMENDATION: 1. The optimizer requires up-to-date statistics for the table in order to select a good execution plan Please gather the stats on tables with PCT Analyzed 100% and no_invalidate=> false option .Make sure No stale stats. 2. Make sure gather stats need to running before Running the job because if you Run it when the job is Running it may impact the Performance 3.As part of STF, providing SQL profile script (attached in case). Before deploying the profile, please follow below steps: a. Cancel the current run of the program. b. DBAs should flush the SQL_ID(byv8at426gqxx) from the shared pool from all the nodes. c. Deploy the profile script. d. Run the program. select * from gv$sql where sql_id ='21anmb829xsyh' ==== Rows Proccessed Observations : -------------- 1. Plan fluctuation 2. Logical I/O s high 3. showing table and index stats are stale and not 100% analysed. Suggestions : 1. Please gather the stats on the tables with 100% with no_invalidate=> false option . 2. Make sure no stale stats on tables and indexes RECOMMENDATION: 1. The optimizer requires up-to-date statistics for the table in order to select a good execution plan Please gather the stats on tables with PCT Analyzed 100% and no_invalidate=> false option . Make sure No stale stats. 2. Make sure gather stats need to running before Running the job because if you Run it when the job is Running it may impact the Performance 3.As part of STF, providing SQL profile script (attached in case). Before deploying the profile, please follow below steps: a. Cancel the current run of the program. b. DBAs should flush the SQL_ID(byv8at426gqxx) from the shared pool from all the nodes. c. Deploy the profile script. d. Run the program. ************************************************************************* SELECT MAX (LAST_ACTIVE_TIME) LAST_ACTIVE_TIME, SQL_ID, PLAN_HASH_VALUE, SUM (EXECUTIONS) EXECUTIONS, sum(fetches) fetches, ROUND (SUM (ELAPSED_TIME) / 1000 / 1000, 2) TOTAL_SEC, ROUND (SUM (DISK_READS) / GREATEST (SUM (EXECUTIONS), 1), 1) PIO_PER_EXEC, ROUND (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1), 1) LIO_PER_EXEC, ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1) ROWS_PER_EXEC, ROUND ( (SUM (BUFFER_GETS) / GREATEST (SUM (EXECUTIONS), 1)) / GREATEST (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1), 1), 1) lio_per_row, ROUND ( (SUM (ELAPSED_TIME) / 1000) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'ms/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000) / GREATEST (SUM (EXECUTIONS), 1), 2) || 'sec/' || ROUND ( (SUM (ELAPSED_TIME) / 1000 / 1000 / 60) / GREATEST (SUM (EXECUTIONS), 1), 1) || 'min' TIME_PER_EXEC, --max(sql_profile) sqlprofile, round( ROUND ( (SUM (ROWS_PROCESSED) / GREATEST (SUM (EXECUTIONS), 1)), 1)/sum(fetches),2) rows_per_fetch FROM GV$SQL WHERE SQL_ID IN ('b7wtvhymg6spy', '82px5przh5h27') GROUP BY SQL_ID, PLAN_HASH_VALUE, TRUNC (LAST_ACTIVE_TIME) ORDER BY 1 DESC; ---------------------How to run tkprof in sql * plus : Step : 1 ALTER SESSION SET TRACEFILE_IDENTIFIER = 'May21'; alter session set max_dump_file_size = unlimited; ALTER SESSION SET TIMED_STATISTICS=TRUE; ALTER SESSION SET EVENTS '10046 trace name context forever, level 12'; SET ARRAYSIZE 5000; SET AUTOTRACE TRACEONLY; var B1 varchar2(32) exec :B1 := '22822281'; var B2 number; exec :B2 := 810270178; SELECT MAX (TRANSACTION_ID), SYSDATE FROM SCD.IF_PRODUCT_MASTER WHERE TRANSACTION_ID > :B2 AND GET_DUNS (PARTNER_ID, PARTNER_ID, '$NA$') = :B1; SET autotrace off; step : 2 : click space in Toad Editor----> run as sql -----> wait and press Enter ----> ed bind.sql Create a text file "bind" and paste below content and close file and run @bind.sql Query to find min and max snap : ================================= SELECT MIN (snap_id), MAX (snap_id) FROM dba_hist_snapshot WHERE begin_interval_time BETWEEN TO_DATE ('10/06/2021 00:20:33', 'MM/DD/YYYY HH24:MI:SS') AND TO_DATE ('10/10/2021 01:19:32', 'MM/DD/YYYY HH24:MI:SS'); To find Cpu usage for concurrent program and sql id : ------------------------------------------------------ SELECT parsing_schema_name,sql_id,osuser,module, SUM (total_elapsed_secs) "Elapsed secs", SUM (total_cpu_secs) "CPU secs", SUM (percent_overall_cpu_used) "% CPU used", SUM (total_dbtime_secs) "DBTIME secs", SUM (percent_overall_dbtime_used) "% DBTIME used", SUM (total_buf_gets) "Buffer Gets", SUM (percent_overall_buf_gets_used) "% Buffer Gets", SUM (total_disk_reads) "Disk Reads", SUM (pct_overall_disk_reads_used) "% Disk Reads" FROM (SELECT mod_sql_list.*, SUM (total_cpu_secs) OVER (PARTITION BY NULL) overall_cpu_time_used, SUM (total_dbtime_secs) OVER (PARTITION BY NULL) overall_dbtime_used, -- SUM (total_elapsed_secs) OVER (PARTITION BY NULL) overall_elapsed_time_used, ROUND ( total_cpu_secs / SUM (total_cpu_secs) OVER (PARTITION BY NULL) * 100, 3) Percent_overall_CPU_used, ROUND ( total_dbtime_secs / SUM (total_dbtime_secs) OVER (PARTITION BY NULL) * 100, 3) Percent_overall_DBTIME_used, -- ,ROUND(total_elapsed_secs / SUM (total_elapsed_secs) OVER (PARTITION BY NULL)*100, 3) Percent_overall_Elapsed ROUND ( total_buf_gets / SUM (total_buf_gets) OVER (PARTITION BY NULL) * 100, 2) Percent_overall_Buf_Gets_used, ROUND ( total_disk_reads / SUM (total_disk_reads) OVER (PARTITION BY NULL) * 100, 2) Pct_overall_disk_reads_used FROM ( SELECT s.parsing_schema_name, s.sql_id,(select username from xxcpf_pm_snapshot where sql_id=s.sql_id and rownum=1) OSUSER, s.module, ROUND (SUM (cpu_time_delta) / 1000000) total_cpu_secs, ROUND (SUM (elapsed_time_delta) / 1000000) total_elapsed_secs, ROUND (SUM (clwait_delta) / 1000000) total_cluster_wait_secs, ROUND ( SUM ( cpu_time_delta + iowait_delta + clwait_delta + apwait_delta + ccwait_delta) / 1000000) total_dbtime_secs, -- non-idle waits ROUND ( SUM (cpu_time_delta) / 1000000 / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta)), 2) cpu_sec_per_exec, ROUND ( SUM (elapsed_time_delta) / 1000000 / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta)), 2) elap_sec_per_exec, SUM (executions_delta) execs, SUM (buffer_gets_delta) total_buf_gets, SUM (disk_reads_delta) total_disk_reads, SUM (iowait_delta) total_iowait, ROUND ( SUM (buffer_gets_delta) / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta))) buf_gets_per_exec FROM dba_hist_sqlstat s, dba_hist_snapshot ss WHERE 1 = 1 AND s.instance_number = ss.instance_number AND s.snap_id = ss.snap_id AND s.dbid = ss.dbid AND ss.instance_number = :inst_id AND ss.snap_id BETWEEN 47409 AND 48128 AND ss.dbid = (SELECT dbid FROM v$database) GROUP BY s.parsing_schema_name, s.sql_id,s.module) mod_sql_list) summary_list GROUP BY parsing_schema_name, sql_id,osuser,module --having sum(percent_overall_buf_gets_used) > 1 order by "% CPU used" desc; Note : if table or view does not exist ----> means snapping not enabled so replace this select username from xxcpf_pm_snapshot where sql_id=s.sql_id and rownum=1---- any string i.e 'abcd' ------------------------------- SELECT parsing_schema_name,sql_id,osuser,module, SUM (total_elapsed_secs) "Elapsed secs", SUM (total_cpu_secs) "CPU secs", SUM (percent_overall_cpu_used) "% CPU used", SUM (total_dbtime_secs) "DBTIME secs", SUM (percent_overall_dbtime_used) "% DBTIME used", SUM (total_buf_gets) "Buffer Gets", SUM (percent_overall_buf_gets_used) "% Buffer Gets", SUM (total_disk_reads) "Disk Reads", SUM (pct_overall_disk_reads_used) "% Disk Reads" FROM (SELECT mod_sql_list.*, SUM (total_cpu_secs) OVER (PARTITION BY NULL) overall_cpu_time_used, SUM (total_dbtime_secs) OVER (PARTITION BY NULL) overall_dbtime_used, -- SUM (total_elapsed_secs) OVER (PARTITION BY NULL) overall_elapsed_time_used, ROUND ( total_cpu_secs / SUM (total_cpu_secs) OVER (PARTITION BY NULL) * 100, 3) Percent_overall_CPU_used, ROUND ( total_dbtime_secs / SUM (total_dbtime_secs) OVER (PARTITION BY NULL) * 100, 3) Percent_overall_DBTIME_used, -- ,ROUND(total_elapsed_secs / SUM (total_elapsed_secs) OVER (PARTITION BY NULL)*100, 3) Percent_overall_Elapsed ROUND ( total_buf_gets / SUM (total_buf_gets) OVER (PARTITION BY NULL) * 100, 2) Percent_overall_Buf_Gets_used, ROUND ( total_disk_reads / SUM (total_disk_reads) OVER (PARTITION BY NULL) * 100, 2) Pct_overall_disk_reads_used FROM ( SELECT s.parsing_schema_name, s.sql_id,('abcd') OSUSER, ----------- s.module, ROUND (SUM (cpu_time_delta) / 1000000) total_cpu_secs, ROUND (SUM (elapsed_time_delta) / 1000000) total_elapsed_secs, ROUND (SUM (clwait_delta) / 1000000) total_cluster_wait_secs, ROUND ( SUM ( cpu_time_delta + iowait_delta + clwait_delta + apwait_delta + ccwait_delta) / 1000000) total_dbtime_secs, -- non-idle waits ROUND ( SUM (cpu_time_delta) / 1000000 / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta)), 2) cpu_sec_per_exec, ROUND ( SUM (elapsed_time_delta) / 1000000 / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta)), 2) elap_sec_per_exec, SUM (executions_delta) execs, SUM (buffer_gets_delta) total_buf_gets, SUM (disk_reads_delta) total_disk_reads, SUM (iowait_delta) total_iowait, ROUND ( SUM (buffer_gets_delta) / DECODE (SUM (executions_delta), 0, -1, SUM (executions_delta))) buf_gets_per_exec FROM dba_hist_sqlstat s, dba_hist_snapshot ss WHERE 1 = 1 AND s.instance_number = ss.instance_number AND s.snap_id = ss.snap_id AND s.dbid = ss.dbid AND ss.instance_number = :inst_id AND ss.snap_id BETWEEN 12417 AND 12563 AND ss.dbid = (SELECT dbid FROM v$database) GROUP BY s.parsing_schema_name, s.sql_id,s.module) mod_sql_list) summary_list GROUP BY parsing_schema_name, sql_id,osuser,module --having sum(percent_overall_buf_gets_used) > 1 order by "% CPU used" desc; ------------------ and then give begin snap i.e and inst id ----- 1 select * from dba_hist_snapshot where trunc(Begin_interval_time)=to_date('11/05/2020' , 'DD/MM/YYYY')----- begin_interval_time------ 12417 select * from dba_hist_snapshot where trunc(Begin_interval_time)=to_date('14/05/2020' , 'DD/MM/YYYY')-----begin_interval_time------- 12563 ------------------------------------------------------------------------------------------------------------------------------------------ With clause : ------------- PLAN_TABLE_OUTPUT SQL_ID 4byampbbvt3r9 -------------------- WITH TEMP AS (SELECT /*+ materialize*/ LOCATION_CODE, ORGANIZATION_ID FROM APPS.XXCTS_OM_LOCATION_V) SELECT /*+ leading(MMT) cardinality(MMT 400) index(XORGS_T XXCTS_PLAN_INTERFACED_ORGS_U2) */ XITEMS.ITEM_NAME, LOC.LOCATION_CODE || '_S', LOC1.LOCATION_CODE || '_L', L.ATTRIBUTE6, 'R', ABS (MMT.TRANSACTION_QUANTITY), MMT.TRANSACTION_DATE, MMT.TRANSACTION_ID FROM MTL_SECONDARY_INVENTORIES MSUB, XXCTS_PLAN_INTERFACED_ORGS XORGS_T, XXCTS_PLAN_INTERFACED_ORGS XORGS, XXCTS_PLAN_INTERFACED_ITEMS XITEMS, TEMP LOC, TEMP LOC1, OE_TRANSACTION_TYPES_ALL OET, MTL_TRANSACTION_TYPES MTT, OE_ORDER_HEADERS_ALL H, OE_ORDER_LINES_ALL L, MTL_MATERIAL_TRANSACTIONS MMT WHERE MMT.TRANSACTION_REFERENCE = TO_CHAR (H.HEADER_ID) AND MMT.SOURCE_LINE_ID = L.LINE_ID AND L.HEADER_ID = H.HEADER_ID AND OET.TRANSACTION_TYPE_ID = H.ORDER_TYPE_ID AND OET.CONTEXT = 'ORDER' AND OET.ATTRIBUTE15 = :B6 AND MTT.TRANSACTION_TYPE_ID = MMT.TRANSACTION_TYPE_ID AND MTT.TRANSACTION_TYPE_NAME IN (:B5 , :B4 ) AND MMT.INVENTORY_ITEM_ID = XITEMS.INVENTORY_ITEM_ID AND XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID = XITEMS.ORGANIZATION_ID AND UPPER (XITEMS.EXTERNAL_APPLICATION) = :B3 AND MMT.ORGANIZATION_ID = LOC.ORGANIZATION_ID AND MMT.ORGANIZATION_ID = XORGS.ORGANIZATION_ID AND UPPER (XORGS.EXTERNAL_APPLICATION) = :B3 AND MMT.TRANSFER_ORGANIZATION_ID = LOC1.ORGANIZATION_ID AND MMT.TRANSFER_ORGANIZATION_ID = XORGS_T.ORGANIZATION_ID AND UPPER (XORGS_T.EXTERNAL_APPLICATION) = :B3 AND UPPER (XORGS_T.SOURCE_LOCATION_FLAG) = 'L' AND TO_TIMESTAMP ( TO_CHAR (MMT.LAST_UPDATE_DATE, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS') > TO_TIMESTAMP (:B2 , 'MM/DD/YYYY HH24:MI:SS') AND TO_TIMESTAMP ( TO_CHAR (MMT.LAST_UPDATE_DATE, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS') <= TO_TIMESTAMP ( TO_CHAR (:B1 , 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS') AND MMT.TRANSACTION_QUANTITY < 0 AND MSUB.ORGANIZATION_ID = MMT.ORGANIZATION_ID AND MSUB.SECONDARY_INVENTORY_NAME = MMT.SUBINVENTORY_CODE AND MSUB.AVAILABILITY_TYPE = 1 AND EXISTS (SELECT NULL FROM CSD_REPAIRS CR, PO_REQUISITION_LINES_ALL PRL, OE_TRANSACTION_TYPES_TL LT, OE_ORDER_LINES_ALL SOL WHERE CR.REPAIR_NUMBER = L.ATTRIBUTE6 AND LT.TRANSACTION_TYPE_ID = SOL.LINE_TYPE_ID AND LT.LANGUAGE = USERENV ('LANG') AND SOL.SOURCE_DOCUMENT_LINE_ID = PRL.REQUISITION_LINE_ID AND LT.NAME LIKE 'SERVICE RPR%' AND PRL.SOURCE_ORGANIZATION_ID = CR.RETURN_ATTRIBUTE3 AND PRL.SOURCE_SUBINVENTORY = XXCTS_RPR_CSD_COMMON_UTILITY.GET_SUB_INVENTORY ( 'SOURCE', TO_NUMBER (CR.RETURN_ATTRIBUTE3), 'SERVICE REPAIR') AND PRL.DESTINATION_ORGANIZATION_ID = CR.RETURN_ATTRIBUTE4 AND PRL.DESTINATION_SUBINVENTORY = XXCTS_RPR_CSD_COMMON_UTILITY.GET_SUB_INVE NTORY ( 'DESTINATION', TO_NUMBER (CR.RETURN_ATTRIBUTE4), 'SERVICE REPAIR')) UNION SELECT /*+ leading(MMT) cardinality(MMT 400) index(XORGS_T XXCTS_PLAN_INTERFACED_ORGS_U2) */ XITEMS.ITEM_NAME, LOC.LOCATION_CODE || '_S' LOCATION_CODE, LOC1.LOCATION_CODE || '_L' LOCATION_CODE1, L.REFERENCE, 'R', ABS (MMT.TRANSACTION_QUANTITY), MMT.TRANSACTION_DATE, MMT.TRANSACTION_ID FROM XXCTS_PLAN_INTERFACED_ORGS XORGS_T, XXCTS_PLAN_INTERFACED_ORGS XORGS, XXCTS_PLAN_INTERFACED_ITEMS XITEMS, TEMP LOC, TEMP LOC1, MFG_LOOKUPS MFG, MTL_TRANSACTION_TYPES MTT, MTL_TXN_REQUEST_HEADERS H, MTL_TXN_REQUEST_LINES L, MTL_MATERIAL_TRANSACTIONS MMT WHERE MMT.SOURCE_LINE_ID = L.LINE_ID AND L.HEADER_ID = H.HEADER_ID AND MFG.LOOKUP_TYPE = 'MOVE_ORDER_TYPE' AND MFG.LOOKUP_CODE = H.MOVE_ORDER_TYPE AND MTT.TRANSACTION_TYPE_ID = MMT.TRANSACTION_TYPE_ID AND MTT.TRANSACTION_TYPE_NAME IN (:B7 ) AND MMT.INVENTORY_ITEM_ID = XITEMS.INVENTORY_ITEM_ID AND XXCTS_SLM_ORGMAINT.GET_MASTER_ORG_ID = XITEMS.ORGANIZATION_ID AND UPPER (XITEMS.EXTERNAL_APPLICATION) = :B3 AND MMT.ORGANIZATION_ID = LOC.ORGANIZATION_ID AND MMT.ORGANIZATION_ID = XORGS.ORGANIZATION_ID AND UPPER (XORGS.EXTERNAL_APPLICATION) = :B3 AND MMT.TRANSFER_ORGANIZATION_ID = LOC1.ORGANIZATION_ID AND MMT.TRANSFER_ORGANIZATION_ID = XORGS_T.ORGANIZATION_ID AND UPPER (XORGS_T.SOURCE_LOCATION_FLAG) = 'L' AND UPPER ----------------------- Script to genetare sql profile ------------------------click F5 pass sql id and plan hash --NEW modified script for sql profile 2015-07-30 --Remember to check the Child Number from gv$sql_plan --Inputs are SQL ID and Child Number from gv$sql_plan -- Do not delete or change any of the following text -- set pagesize 0 set line 1999 set verify off; set TRIMOUT ON; set heading off; set feedback off; set echo off; --def sql_id = &&sql_id_value --def child_number = &&child_number_value --def plan_hash_valve=&&plan_hash_value SELECT '--This Script will generate SQL PROFILE for SQL ID: ' || '&&SQL_ID' || CHR (10) FROM DUAL; SELECT CHR (10) || 'Define SQL_ID =' || '''' || '&&SQL_ID' || '''' || ';' FROM DUAL; SELECT CHR (10) || 'DECLARE' || CHR (10) || 'clsql_text CLOB;' || CHR (10) || CHR (10) || 'BEGIN' || CHR (10) || CHR (10) || 'SELECT sql_text INTO clsql_text FROM dba_hist_sqltext where sql_id =' || '''' || '&&SQL_ID' || '''' || ';' || CHR (10) FROM DUAL; SELECT CHR (10) || 'dbms_sqltune.import_sql_profile(sql_text => clsql_text,' || CHR (10) || CHR (9) || 'profile=> sqlprof_attr(' || CHR (10) || CHR (9) || '''BEGIN_OUTLINE_DATA'',' || CHR (10) FROM DUAL; SELECT CHR (9) || '''' || REGEXP_REPLACE (EXTRACTVALUE (VALUE (d), '/hint'), '''', '''''') || ''',' FROM XMLTABLE ( '/*/outline_data/hint' PASSING (SELECT xmltype (other_xml) AS xmlval FROM dba_hist_sql_plan WHERE sql_id = '&&SQL_ID' AND plan_hash_value = '&&plan_hash_value' AND other_xml IS NOT NULL)) d; SELECT CHR (9) || '''END_OUTLINE_DATA''' || '),' || CHR (10) || 'name =>' || '''PROFILE_' || '&&SQL_ID' || '''' || ',' || CHR (10) || 'force_match=>true);' FROM DUAL; SELECT CHR (10) || 'END;' || CHR (10) || '/' FROM DUAL; select CHR(10) from dual; ===== one more script to generate sql profile --NEW modified script for sql profile 2015-07-30 --Remember to check the Child Number from gv$sql_plan --Inputs are SQL ID and Child Number from gv$sql_plan -- Do not delete or change any of the following text -- set pagesize 0 set line 1999 set verify off; SET TRIMOUT ON set heading off; set feedback off; set echo off; --def sql_id = &&sql_id_value def child_number = &&child_number_value SELECT '--This Script will generate SQL PROFILE for SQL ID: ' || '&&SQL_ID' || CHR (10) FROM DUAL; SELECT CHR (10) || 'Define SQL_ID =' || '''' || '&&SQL_ID' || '''' || ';' FROM DUAL; SELECT CHR (10) || 'DECLARE' || CHR (10) || 'clsql_text CLOB;' || CHR (10) || CHR (10) || 'BEGIN' || CHR (10) || CHR (10) || 'SELECT sql_text INTO clsql_text FROM GV$sql where sql_id =' || '''' || '&&SQL_ID' || '''' || ';' || CHR (10) FROM DUAL; SELECT CHR (10) || 'dbms_sqltune.import_sql_profile(sql_text => clsql_text,' || CHR (10) || CHR (9) || 'profile=> sqlprof_attr(' || CHR (10) || CHR (9) || '''BEGIN_OUTLINE_DATA'',' || CHR (10) FROM DUAL; SELECT CHR (9) || '''' || REGEXP_REPLACE (EXTRACTVALUE (VALUE (d), '/hint'), '''', '''''') || ''',' FROM XMLTABLE ( '/*/outline_data/hint' PASSING (SELECT xmltype (other_xml) AS xmlval FROM gv$sql_plan WHERE sql_id = '&&SQL_ID' AND CHILD_NUMBER = '&&child_number' AND other_xml IS NOT NULL)) d; SELECT CHR (9) || '''END_OUTLINE_DATA''' || '),' || CHR (10) || 'name =>' || '''PROFILE_' || '&&SQL_ID' || '''' || ',' || CHR (10) || 'force_match=>true);' FROM DUAL; SELECT CHR (10) || 'END;' || CHR (10) || '/' FROM DUAL; select CHR(10) from dual; ====== other script for sql profile DECLARE ar_profile_xml CLOB; cl_sql_text CLOB; BEGIN -- get source sql_id information from good plan -- SELECT REGEXP_REPLACE (other_xml, '.*(<outline_data>.*</outline_data>).*', '\1') INTO ar_profile_xml FROM dba_hist_sql_plan WHERE sql_id = '7g2979vus3h6d' AND PLAN_HASH_VALUE = 3111136292--source SQL_ID with good plan AND child_number = 0 AND other_xml IS NOT NULL AND ROWNUM = 1; -- get information of target sql_id -- BEGIN SELECT sql_fulltext INTO cl_sql_text FROM dba_hist_sqltext WHERE sql_id = '0ajb70dnwntwz'; EXCEPTION WHEN NO_DATA_FOUND THEN SELECT sql_text INTO cl_sql_text FROM dba_hist_sqltext WHERE sql_id = '0ajb70dnwntwz' AND dbid = (SELECT dbid FROM gv$database); END; -- fix Profile DBMS_SQLTUNE.import_sql_profile ( sql_text => cl_sql_text, profile_xml => ar_profile_xml, name => 'PROFILE_0ajb70dnwntwz', force_match => TRUE); END; =============== way to generate sql profile script SQL> @coe_xfr_sql_profile.sql Parameter 1: SQL_ID (required) Enter value for 1: 9m4fshxh5azcb PLAN_HASH_VALUE AVG_ET_SECS --------------- ----------- 3082536350 65908.371 3884177337 110866.762 528415816 112863.198 95515781 126667.717 Parameter 2: PLAN_HASH_VALUE (required) Enter value for 2: 3082536350 Values passed: ~~~~~~~~~~~~~ SQL_ID : "9m4fshxh5azcb" PLAN_HASH_VALUE: "3082536350" Execute coe_xfr_sql_profile_9m4fshxh5azcb_3082536350.sql on TARGET system in order to create a custom SQL Profile with plan 3082536350 linked to adjusted sql_text. COE_XFR_SQL_PROFILE completed. ====== query to get optimizer hints or scaling set serveroutput on echo off declare -- input variables input_task_owner dba_advisor_tasks.owner%type:='&task_owner'; input_task_name dba_advisor_tasks.task_name%type:='&task_name'; input_show_outline boolean:=false; -- local variables task_id dba_advisor_tasks.task_id%type; outline_data xmltype; benefit number; begin for o in ( select * from dba_advisor_objects where owner=input_task_owner and task_name=input_task_name and type='SQL') loop -- get the profile hints (opt_estimate) dbms_output.put_line('--- PROFILE HINTS from '||o.task_name||' ('||o.object_id||') statement '||o.attr1||':'); dbms_output.put_line('/*+'); for r in ( select hint,benefit from ( select case when attr5 like 'OPT_ESTIMATE%' then cast(attr5 as varchar2(4000)) when attr1 like 'OPT_ESTIMATE%' then attr1 end hint,benefit from dba_advisor_recommendations t join dba_advisor_rationale r using (task_id,rec_id) where t.owner=o.owner and t.task_name = o.task_name and r.object_id=o.object_id and t.type='SQL PROFILE' --and r.message='This attribute adjusts optimizer estimates.' ) order by to_number(regexp_replace(hint,'^.*=([0-9.]+)[^0-9].*$','\1')) ) loop dbms_output.put_line(' '||r.hint); benefit:=to_number(r.benefit)/100; end loop; dbms_output.put_line('*/'); -- get the outline hints begin select outline_data into outline_data from ( select case when other_xml is not null then extract(xmltype(other_xml),'/*/outline_data/hint') end outline_data from dba_advisor_tasks t join dba_sqltune_plans p using (task_id) where t.owner=o.owner and t.task_name = o.task_name and p.object_id=o.object_id and t.advisor_name='SQL Tuning Advisor' --11gonly-- and execution_type='TUNE SQL' and p.attribute='Using SQL profile' ) where outline_data is not null; exception when no_data_found then null; end; exit when not input_show_outline; dbms_output.put_line('--- OUTLINE HINTS from '||o.task_name||' ('||o.object_id||') statement '||o.attr1||':'); dbms_output.put_line('/*+'); for r in ( select (extractvalue(value(d), '/hint')) hint from table(xmlsequence(extract( outline_data , '/'))) d ) loop dbms_output.put_line(' '||r.hint); end loop; dbms_output.put_line('*/'); dbms_output.put_line('--- Benefit: '||to_char(to_number(benefit),'FM99.99')||'%'); end loop; dbms_output.put_line(''); end; / ============ Note : ------ pass sql id and PHV TO check sql profile deployed or not and picking or not ======================================================= select * from dba_sql_profiles where name like 'PROFILE_6f72pu9v2psdr' select * from gv$sql where sql_id='6f72pu9v2psdr' select * from dba_sql_profiles where name like 'PROFILE_dnvmd979qnnfv' select * from gv$sql where sql_id='dnvmd979qnnfv' copy output of the script and give it as sql profile (remove if any space when starting with '') -------------------------------------------------------------------------------------------------------------------------------------------------------------- select /*+parallel(32)*/RUN_STATUS,count(*) from WFPUBLISH.XXDH_OUTBOUND_REQUESTS group by RUN_STATUS order by 2 desc execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30); SELECT RECORD_STATUS,COMMENTS FROM WFPUBLISH.XXDH_ATS_JOBTITLE_MAPPING_STG WHERE REQUEST_ID IN (SELECT REQUEST_ID FROM WFPUBLISH.XXDH_OUTBOUND_REQUESTS WHERE RUN_STATUS = 'R' AND TRUNC (START_DATE) < TRUNC (SYSDATE)) AND RECORD_STATUS = 'N' SOURCE_DATABASE_NAME SOURCE_SCHEMA_NAME TARGET_DATABASE_NAME TARGET_SCHEMA_NAME DB_LINK_NAME DV1CFS XXCFSFND CFSPRD XXCFSPRC QUOTEADM DV1CFS XXCFSFND CG1PRD_SRVC_OTH APPSRO CG1 DV1CFS XXCFSFND CLFPRD APPSRO APPSRO DV1CFS XXCFSFND CLFPRD APPSRO XXCFSFND_CLFPRD_APPSRO DV1CFS XXCFSFND CLFPRD XXCLFST TS2CLF DV1CFS XXCFSFND CLFPRD XXCLFST XXCFSFND_CLFPRD_XXCLFST DV1CFS XXCFSFND CLFPRD XXCLFST XXCLFST DV1CFS XXCFSFND CRTPRD XXNGCR_RO CRTPRD DV1CFS XXCFSFND FNTR2PRD CSC_MIDAS CSC_MIDAS DV1CFS XXCFSPRC DMPROD XXQ2O_CPS_U CSCMDMLINK DV1CFS XXCFSPRC FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM DV1CFS XXCFSPRC FNTR2PRD QUOTEADM QUOTEADM DV1CFS XXCFSQ2A CLFPRD APPSRO CLF DV1CFS XXCFSQ2A ESALESPD SFA_READ ESALES DV1CFS XXCFSQ2A FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM DV1CFS XXCFSQ2A FNTR2PRD ELESEUSR ELESEUSR DV1CLF APPS CLFPRD APPSRO XXCLF_CLFPRD_DV1_ROUSER DV1CLF XXCLF FNTR2PRD READONLYUSER XXCLF_FNTR2PRD_TREASURY_ROUSER CREATE table XXDH_OUTBOUND_REQUESTS_TEMP as select * from WFPUBLISH.XXDH_OUTBOUND_REQUESTS create index RUN_STATUS_IDX on XXDH_OUTBOUND_REQUESTS_TEMP(RUN_STATUS) execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30); SELECT NVL (COUNT (1), 0) FROM XXICM.XXICM_TRANS_LOAD_TRACKING WHERE TABLE_NAME = :B4 AND PARENT_REQUEST_ID = NVL (:B3, PARENT_REQUEST_ID) AND NVL (STATUS, 'N') = 'R' AND NVL (ORG_ID, 1) = NVL (:B2, 1) AND NVL (DATA_SOURCE, 'ZZZ') = NVL (:B1, 'ZZZ') 16354 cr 16440 after index and histogram CREATE INDEX XXCTS_COMP_INV_NO_TRM ON XXCTS_COMP_EXP_LINES_TEAMP (TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID")) CREATE INDEX XXCTS_COMP_LINES_TPL_HDR ON XXCTS_COMP_EXP_LINES_TEAMP (TPL_HDR_ID) CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK ON XXCTS_COMP_EXP_LINES_TEAMP (INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11) Hi All, The Top SQL reports, Host Analysis & the MOM can also be found at http://prfrcdn-prd-1:8080/perf_mon/ Points Discussed: • Top SQL analysis for time period 27-Mar-2020 to 21-Apr-2020 APPS Report: • No Problematic SQLs found. DB Report • No SQLs identified as problematic for case creation. DB Link Report • No issues observed. Wait event Report: • No Problematic SQLs found. Action on Perf Team: NA Action on App team: NA =========================== https://examv2.cloudapps.cisco.com/extranet/ExAMV2/nsrhomepagereq.action https://dbaas.cisco.com/AllAboutDB/home#/dbDown/ ------------Db List Link create table EXP_LINES_TEMP3 as select * from XXCTS_O.XXCTS_COMP_EXP_LINES CREATE INDEX PT_NO_IDX ON EXP_LINES_TEMP3(TRIM("PART_NO")) SELECT /*+INDEX(A PT_NO_IDX)*/ NVL (HTS_SCHEDULE_B_NO, NULL) FROM EXP_LINES_TEMP3 A, XXCCS_BOP_O.XXCCS_BOP_OE_SHIPMENT_LINES SHPLNS WHERE TRIM (A.INVOICE_NO) = SHPLNS.DELIVERY_ID AND TRIM (A.PART_NO) = :B2 AND TRIM (TO_CHAR (A.DELIVERY_DETAIL_ID)) = SHPLNS.DELIVERY_DETAIL_ID AND PROCESS_CODE = 'OUTBOUND' AND :B1 = SHPLNS.DELIVERY_ID CREATE INDEX XXCTS_COMP_INV_NO_TRM1 ON EXP_LINES_TEMP3 (TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID"))) CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK1 ON EXP_LINES_TEMP3 (INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11) -------------------------------------------------------------- CREATE table OTMM_JOB_EXECUTION_TEMP as select * from OTMMCORE.OTMM_JOB_EXECUTION create index PARENT_JOB_INSTANCE_ID_INDX on OTMM_JOB_EXECUTION_TEMP(PARENT_JOB_INSTANCE_ID) CREATE table COM_ORDER_MAPPER_T as select * from COMUSER.COM_ORDER_MAPPER where rownum<1000000 create index IDX_COM_ORDER_MAPPER_T on COM_ORDER_MAPPER_T(status) SELECT /*+ INDEX(A PARENT_JOB_INSTANCE_ID_INDX)*/ JOB_EXECUTION_ID, JOB_INSTANCE_ID, STATUS FROM OTMM_JOB_EXECUTION_TEMP A WHERE PARENT_JOB_INSTANCE_ID = :1 ------->Index Range Scan -------------------------------------------------------------------------------------------------------------------------------- This case has been created through ExAM V2 for UBVPN Account Creation Partner Name: TCS (aka Tata Consultancy Services) Partner Site Known Name: tcs10-in Location: 801, 901, & 1001 KENSINGTON 'A' WING HIRANANDANI BUILDERS SPECIAL ECONOMIC ZONE POWAI,Mumbai,Maharashtra,INDIA Business Function: IT Applications Development Business Sponsor ID: rdharmen Billing Dept No: 020071578 List of Users to be created: ============================ User ID: makancha User Name: Madan Kumar Kancharla Manager Approved ID: ywadhavk Manager Approved Date: 04/16/2020 Hi Manish Thanks for contacting accounts team Account migration is completed. The next token generated will allow you to connect GEM cluster(bgl13-gem-ubvpn-gw1a.cisco.com / bgl13-gem-ubvpn-gw2a.cisco.com ). In the future, if the password prompt loops please get new passwords until one is accepted. I am marking the case as resolved but it can be reopened within 5 days. ESP system will close the case at the 5 day mark and it cannot be re-opened. However, if there is still an issue, please contact me (ppenumat@cisco.com) and I will be happy to further assist you. "HOW TO REOPEN YOUR TICKET WITHIN 5 DAYS" - https://cisco.service-now.com/sp?id=kb_article&sys_id=9a8a31e3dbfbef4039fe9c9adb96198c We would love to hear your experience in the manner the incident was managed. Please share your feedback online or via an Email to my manager (lognagar@cisco.com). Also, share any areas of opportunity (if any) to improve the remote support service. Regards Prudhvi raj =============== josh arora set linesize 750 pages 9999 column box format a30 column spid format a10 column username format a30 column program format a30 column os_user format a20 col LOGON_TIME for a20 select b.inst_id,b.sid,b.serial#,a.spid, substr(b.machine,1,30) box,to_char (b.logon_time, 'dd-mon-yyyy hh24:mi:ss') logon_time, substr(b.username,1,30) username, substr(b.osuser,1,20) os_user, substr(b.program,1,30) program,status,b.last_call_et AS last_call_et_secs,b.sql_id from gv$session b,gv$process a where b.paddr = a.addr and a.inst_id = b.inst_id and type='USER' and b.status='ACTIVE' order by logon_time; =============== https://ardentperf.com/2007/09/12/gc-buffer-busy-waits-in-rac-finding-hot-blocks/ select min(begin_interval_time) min, max(end_interval_time) max from dba_hist_snapshot where snap_id between 129615 and 129616; select wait_class_id, wait_class, count(*) cnt from dba_hist_active_sess_history where snap_id between 129615 and 129616 group by wait_class_id, wait_class order by 3; select event_id, event, count(*) cnt from dba_hist_active_sess_history where snap_id between 129615 and 129616 and wait_class_id=3871361733 group by event_id, event order by 3; select sql_id, count(*) cnt from dba_hist_active_sess_history where snap_id between 129615 and 129615 and event_id in (2701629120,1520064534) group by sql_id order by 2; select sql_text from dba_hist_sqltext where sql_id='5w6vqmyy956cc'; select count(distinct(current_obj#)) from dba_hist_active_sess_history where snap_id between 129615 and 129615 and event_id=1520064534 and sql_id='5w6vqmyy956cc'; ============ SELECT instance_number, sql_opname,event, p1, p2, p3, current_obj#, COUNT (*) cnt FROM dba_hist_active_sess_history WHERE sample_time BETWEEN TIMESTAMP '2020-11-24 6:30:04' AND TIMESTAMP '2020-11-24 7:30:14' AND wait_class = 'Cluster' GROUP BY instance_number, event, sql_opname,p1, p2, p3, current_obj# ORDER BY cnt DESC / SELECT sql_id, SQL_PLAN_HASH_VALUE, SQL_PLAN_LINE_ID, COUNT (*) cnt FROM dba_hist_active_sess_history h WHERE sample_time BETWEEN TIMESTAMP '2020-11-24 6:30:04' AND TIMESTAMP '2020-11-24 7:30:14' AND wait_class = 'Cluster' and event='gc buffer busy acquire' GROUP BY sql_id, SQL_PLAN_HASH_VALUE, SQL_PLAN_LINE_ID ORDER BY cnt DESC; select * from table(dbms_xplan.display_awr( (select sql_id from dba_hist_sqlstat where PLAN_HASH_VALUE=&&plan_hash and rownum=1), null, null,'ALL')); =========================== https://examv2.cloudapps.cisco.com/extranet/ExAMV2/nsrhomepagereq.action https://dbaas.cisco.com/AllAboutDB/home#/dbDown/ ------------Db List Link create table EXP_LINES_TEMP3 as select * from XXCTS_O.XXCTS_COMP_EXP_LINES CREATE INDEX PT_NO_IDX ON EXP_LINES_TEMP3(TRIM("PART_NO")) SELECT /*+INDEX(A PT_NO_IDX)*/ NVL (HTS_SCHEDULE_B_NO, NULL) FROM EXP_LINES_TEMP3 A, XXCCS_BOP_O.XXCCS_BOP_OE_SHIPMENT_LINES SHPLNS WHERE TRIM (A.INVOICE_NO) = SHPLNS.DELIVERY_ID AND TRIM (A.PART_NO) = :B2 AND TRIM (TO_CHAR (A.DELIVERY_DETAIL_ID)) = SHPLNS.DELIVERY_DETAIL_ID AND PROCESS_CODE = 'OUTBOUND' AND :B1 = SHPLNS.DELIVERY_ID CREATE INDEX XXCTS_COMP_INV_NO_TRM1 ON EXP_LINES_TEMP3 (TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID"))) CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK1 ON EXP_LINES_TEMP3 (INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11) -------------------------------------------------------------- CREATE table OTMM_JOB_EXECUTION_TEMP as select * from OTMMCORE.OTMM_JOB_EXECUTION create index PARENT_JOB_INSTANCE_ID_INDX on OTMM_JOB_EXECUTION_TEMP(PARENT_JOB_INSTANCE_ID) SELECT /*+ INDEX(A PARENT_JOB_INSTANCE_ID_INDX)*/ JOB_EXECUTION_ID, JOB_INSTANCE_ID, STATUS FROM OTMM_JOB_EXECUTION_TEMP A WHERE PARENT_JOB_INSTANCE_ID = :1 ------->Index Range Scan -------------------------------------------------------------------------------------------------------------------------------- This case has been created through ExAM V2 for UBVPN Account Creation Partner Name: TCS (aka Tata Consultancy Services) Partner Site Known Name: tcs10-in Location: 801, 901, & 1001 KENSINGTON 'A' WING HIRANANDANI BUILDERS SPECIAL ECONOMIC ZONE POWAI,Mumbai,Maharashtra,INDIA Business Function: IT Applications Development Business Sponsor ID: rdharmen Billing Dept No: 020071578 List of Users to be created: ============================ User ID: makancha User Name: Madan Kumar Kancharla Manager Approved ID: ywadhavk Manager Approved Date: 04/16/2020 Hi Manish Thanks for contacting accounts team Account migration is completed. The next token generated will allow you to connect GEM cluster(bgl13-gem-ubvpn-gw1a.cisco.com / bgl13-gem-ubvpn-gw2a.cisco.com ). In the future, if the password prompt loops please get new passwords until one is accepted. I am marking the case as resolved but it can be reopened within 5 days. ESP system will close the case at the 5 day mark and it cannot be re-opened. However, if there is still an issue, please contact me (ppenumat@cisco.com) and I will be happy to further assist you. "HOW TO REOPEN YOUR TICKET WITHIN 5 DAYS" - https://cisco.service-now.com/sp?id=kb_article&sys_id=9a8a31e3dbfbef4039fe9c9adb96198c We would love to hear your experience in the manner the incident was managed. Please share your feedback online or via an Email to my manager (lognagar@cisco.com). Also, share any areas of opportunity (if any) to improve the remote support service. Regards Prudhvi raj ================================ select /*+parallel(32)*/RUN_STATUS,count(*) from WFPUBLISH.XXDH_OUTBOUND_REQUESTS group by RUN_STATUS order by 2 desc drop index index name drop table table name create histogram on column RUN_STATUS : execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30); To drop histogram : BEGIN dbms_stats.Delete_column_stats(ownname => 'PERF11I', tabname => 'DIST_T', colname => 'LEDGER_ID', col_stat_type => 'HISTOGRAM'); END; / SELECT RECORD_STATUS,COMMENTS FROM WFPUBLISH.XXDH_ATS_JOBTITLE_MAPPING_STG WHERE REQUEST_ID IN (SELECT REQUEST_ID FROM WFPUBLISH.XXDH_OUTBOUND_REQUESTS WHERE RUN_STATUS = 'R' AND TRUNC (START_DATE) < TRUNC (SYSDATE)) AND RECORD_STATUS = 'N' SOURCE_DATABASE_NAME SOURCE_SCHEMA_NAME TARGET_DATABASE_NAME TARGET_SCHEMA_NAME DB_LINK_NAME DV1CFS XXCFSFND CFSPRD XXCFSPRC QUOTEADM DV1CFS XXCFSFND CG1PRD_SRVC_OTH APPSRO CG1 DV1CFS XXCFSFND CLFPRD APPSRO APPSRO DV1CFS XXCFSFND CLFPRD APPSRO XXCFSFND_CLFPRD_APPSRO DV1CFS XXCFSFND CLFPRD XXCLFST TS2CLF DV1CFS XXCFSFND CLFPRD XXCLFST XXCFSFND_CLFPRD_XXCLFST DV1CFS XXCFSFND CLFPRD XXCLFST XXCLFST DV1CFS XXCFSFND CRTPRD XXNGCR_RO CRTPRD DV1CFS XXCFSFND FNTR2PRD CSC_MIDAS CSC_MIDAS DV1CFS XXCFSPRC DMPROD XXQ2O_CPS_U CSCMDMLINK DV1CFS XXCFSPRC FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM DV1CFS XXCFSPRC FNTR2PRD QUOTEADM QUOTEADM DV1CFS XXCFSQ2A CLFPRD APPSRO CLF DV1CFS XXCFSQ2A ESALESPD SFA_READ ESALES DV1CFS XXCFSQ2A FNRP2PRD CAPITAL_DM_RO DM_CORE_ADM DV1CFS XXCFSQ2A FNTR2PRD ELESEUSR ELESEUSR DV1CLF APPS CLFPRD APPSRO XXCLF_CLFPRD_DV1_ROUSER DV1CLF XXCLF FNTR2PRD READONLYUSER XXCLF_FNTR2PRD_TREASURY_ROUSER CREATE table XXDH_OUTBOUND_REQUESTS_TEMP as select * from WFPUBLISH.XXDH_OUTBOUND_REQUESTS create index RUN_STATUS_IDX on XXDH_OUTBOUND_REQUESTS_TEMP(RUN_STATUS) execute dbms_stats.gather_table_stats('PERF11I','XXDH_OUTBOUND_REQUESTS_TEMP',estimate_percent=>dbms_stats.auto_sample_size, METHOD_OPT => 'FOR COLUMNS RUN_STATUS',cascade=>true,degree=>30); SELECT NVL (COUNT (1), 0) FROM XXICM.XXICM_TRANS_LOAD_TRACKING WHERE TABLE_NAME = :B4 AND PARENT_REQUEST_ID = NVL (:B3, PARENT_REQUEST_ID) AND NVL (STATUS, 'N') = 'R' AND NVL (ORG_ID, 1) = NVL (:B2, 1) AND NVL (DATA_SOURCE, 'ZZZ') = NVL (:B1, 'ZZZ') 16354 cr 16440 after index and histogram *************** CREATE table am_domain_T as select * from EMANADM.am_domain where rownum <1000000 create index IDX_am_domain_T on am_domain_T(parent_domain_id) ******************** CREATE INDEX XXCTS_COMP_INV_NO_TRM ON XXCTS_COMP_EXP_LINES_TEAMP (TRIM("INVOICE_NO"), TRIM("PART_NO"), TRIM(TO_CHAR("DELIVERY_DETAIL_ID")) CREATE INDEX XXCTS_COMP_LINES_TPL_HDR ON XXCTS_COMP_EXP_LINES_TEAMP (TPL_HDR_ID) CREATE UNIQUE INDEX XXCTS_INV_INVOICE_ITEM_PK ON XXCTS_COMP_EXP_LINES_TEAMP (INVOICE_NO, ITEM_NO, PROCESS_CODE, ATTRIBUTE11) DROP INDEX ord_customer_ix_demo; create table XXODI_OE_ORDER_LINES_HISTORY_T as select * from XXODI.XXODI_OE_ORDER_LINES_HISTORY where rownum <1000000 create index HIST_TYPE_CODE_IDX1 on XXODI_OE_ORDER_LINES_HISTORY_T(HIST_CREATION_DATE,HIST_TYPE_CODE) Hi All, The Top SQL reports, Host Analysis & the MOM can also be found at http://prfrcdn-prd-1:8080/perf_mon/ Points Discussed: • Top SQL analysis for time period 27-Mar-2020 to 21-Apr-2020 APPS Report: • No Problematic SQLs found. DB Report • No SQLs identified as problematic for case creation. DB Link Report • No issues observed. Wait event Report: • No Problematic SQLs found. Action on Perf Team: NA Action on App team: NA ====================================================== sql tuning advisary declare task_nm varchar2(100); begin task_nm := dbms_sqltune.create_tuning_task(SQL_ID=> '&SQL_ID',TASK_NAME => 'SQL_TUNNING_TASK_SQL_ID'); end; / SQL> SELECT task_name, status FROM dba_advisor_log WHERE task_name = '&TASK_NAME'; exec dbms_sqltune.execute_tuning_task (TASK_NAME => '&TASK_NAME'); SQL>SET LONG 10000; SQL>SET PAGESIZE 1000 SQL> SQL> SELECT DBMS_SQLTUNE.report_tuning_task('&TASK_NAME') AS recommendations FROM dual; SQL>SET PAGESIZE 24 ================================ Performance team - Oracle 19c upgrade Run Book Pre-Upgrade 19c Activity: All below activities as mentioned are used to carry out in the Non-PROD environment after 19c Upgrade: i. First, we have to enable the snapping for all respective Non-PROD database where the application will do testing. ii. Validate all the parameters at the database level before the environment get release to the app team. iii. Once App team will start the testing, they will share the Start date of the testing with Perf team iv. We used to do Top SQL analysis on periodically basis and share the analysis with app team if any SQLs identify as regressed will highlight and will provide recommendation for it. v. As part of proactive measure, performance team used to do plan change analysis activity. vi. As a part of proactively validation of Critical programs, will create AWR baseline for the problematic duration post upgrade 19c. vii. As a part of proactive measure to identify the regress concurrent programs performance, will used to do concurrent program comparison analysis. Post Upgrade 19c Activity: All below activities as mentioned are used to carry out in the PROD environment after 19c Upgrade: i. Validate the snapping enablement after 19c upgrade to PROD environment. ii. Validate the parameters at the database level. iii. Provide normalization support after 19c upgrade for two weeks. iv. Create AWR base creation after 19c upgrade and generate the comparison report. =============== OJVM: https://mikedietrichde.com/2016/09/05/the-ojvm-patching-saga-and-how-to-solve-it-part-i/ Josh Arora 2/2/2021, 1:34 AM The actual steps recommenced by oracle support are listed below - 1.Install the DBRU patch on 12.2 home 2.upgrade the database (datapatch will run during post upgrade steps) 3.Please check the upgrade log whether datapatch completed successfully or not 4.If datapatch failed during post upgrade steps please rerun the datapatch maually for the DBRU patch before installing the OJVM RU 3. Install the OJVM RU 4.Run post install steps for OJVM RU ——- end of support details – – – – Hope this helps others too….. Josh Arora 2/2/2021, 1:35 AM You can use opatchauto if you are applying this OJVM patch in 12.2 now . And Yes there is no documentation about it but it is understood to be the case for RAC. Or you can apply the single patch with the opatch apply command. “And Yes there is no documentation about it”. Hm … I disagree with the step to do the OJVM separately after the upgrade. I don’t see why this should happen just after upgrade. Some interesting facts about OJVM Suraj Ramchander 2/2/2021, 1:36 AM thanks I have asked them to reach out to oracle if it occurs again and again Josh Arora 2/2/2021, 1:37 AM Suraj this incident ticket # INC3035477 would be a great example for this scenario for the database G2CPRD Kindly discuss this in the upcoming weekly meeting it s a great learning experience for everyone Suraj Ramchander 2/2/2021, 1:38 AM sure Josh Arora 2/2/2021, 1:38 AM and the pains and sagas revolving around OVJM thanxs much great work Josh Arora 2/2/2021, 1:39 AM Yes reaching out to oracle is the absolute correct approach for these kind of waits as they are not clearly documented and ironically have changed in 21c release Suraj Ramchander 2/2/2021, 1:40 AM yeah Josh Arora 2/2/2021, 1:40 AM MOS Note: 1929745.1 – Oracle Recommended Patches — “Oracle JavaVM Component Database PSU and Update” (OJVM PSU and OJVM Update) Patches I spoke to some RAC directors at oracle 15 mins ago They recommended reading the above mentioned MOS note Josh Arora 2/2/2021, 1:42 AM One final question needs to remain unanswered: Why do we deliver COMBO patches with GI and OJVM? I have seriously no idea. And the README doesn’t shed some light here either. Actually, the reason is that the COMBO patch delivers everything despite that fact that it’s called GI+OJVM – it has the database patch bundle included, too. Cool stuff - back to ranch ***** Session is not progressing for OJVM:generic wait event. Can you please restart your application because the cause: Bug 10325230 which can cause a hang when user threads access java.lang.Process input streams while Resource Manager is active. IncidentINC3035477 ------ INC0205114 DB: G2CPRD Issue: Order Import program running long. REQUEST_ID - 211528494 INST_ID - 1 SID - 3809 SERIAL# - 65261 Top SQLs are given below. SQL_ID EVENT CURROBJNAME COUNT(*) ------------- -------------- ------------- -------- 5rvh7z9yrwmmp OJVM: Generic 7956 5rvh7z9yrwmmp 1 SQL_TEXT: BEGIN xxg2c_auto_res_term_pkg.res_terminate(:errbuf,:rc,:A0,:A1); END; SQL_ID: 5rvh7z9yrwmmp is the top SQL and currently hanged with wait-event - OJVM: Generic and is not a performance issue. This wait-event is usally associated with the resource manager and caused due to some internal polling mechanism that has gone wrong causing a hang. Whenever I have seen this wait-event in past (quite rare), a simple restart has fixed the issue. If it resurfaces again and again, then maybe we are hitting a bug and Oracle should be involved. Thanks & Regards, Suraj ***************************************************************************** alter session set optimizer_features_enable = '12.1.0.2'; alter session set optimizer_features_enable = '19.1.0'; ALTER SESSION SET "_optimizer_cbqt_or_expansion"= off; SELECT /*+ OPTIMIZER_FEATURES_ENABLE('19.1.0') */ ATTRIB.OA_ATTRIB_ID FROM APPS.XXOA_ORDER_ATTRIB_WIPS ATTRIB WHERE (ATTRIB.LINE_ID = :B3 OR ATTRIB.PARENT_LINE_ID = :B3) AND ATTRIB.VERSION_ID = :B2 SELECT /*+ opt_param('_optimizer_cbqt_or_expansion','off') */ ATTRIB.OA_ATTRIB_ID FROM APPS.XXOA_ORDER_ATTRIB_WIPS ATTRIB WHERE (ATTRIB.LINE_ID = :B3 OR ATTRIB.PARENT_LINE_ID = :B3) AND ATTRIB.VERSION_ID = :B2 ******************************************************************************************  




SELECT /*+ opt_param('_optimizer_cbqt_or_expansion','off') */ ATTRIB.OA_ATTRIB_ID

             FROM APPS.XXOA_ORDER_ATTRIB_WIPS ATTRIB

            WHERE     (ATTRIB.LINE_ID = :B3 OR ATTRIB.PARENT_LINE_ID = :B3)

                  AND ATTRIB.VERSION_ID = :B2


******************************************************************************************

Comments

Popular posts from this blog

Original: SQL Tune Report–sqltrpt.sql

SQL Performance issues basic Troubleshooting Stpes

Performance Tuning Level - I