Search This Blog

Total Pageviews

Sunday, 27 October 2024

Patch 36916690 - GI Release Update 19.25.0.0


Patch 
36916690
 - GI Release Update 19.25.0.0 

How to Patch Oracle Grid Infrastructure 19c ?





p36916690_190000_Linux-x86-64.zip   <<<<<for Oracle Interim Patch Installer version 12.2.0.1.44 OPatch 12.2.0.1.44 for DB 23.0.0.0.0 (Oct 2024)



download below  --
https://updates.oracle.com/download/6880880.html
OPatch 12.2.0.1.44 for DB 23.0.0.0.0 (Oct 2024)

unzip -q p6880880_230000_Linux-x86-64.zip -d /u01/app/19.0.0/grid
replace /u01/app/19.0.0/grid/OPatch/opatchauto? [y]es, [n]o, [A]ll, [N]one, [r]ename: A





Patch: /home/grid/36916690/36917397
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_10-51-34AM_1.log
Reason: Failed during Analysis: CheckSystemSpace Failed, [ Prerequisite Status: FAILED, Prerequisite output:
The details are:
Required amount of space(12173.691MB) is not available.]


Patch: /home/grid/36916690/36758186
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_10-51-34AM_1.log
Reason: Failed during Analysis: CheckSystemSpace Failed, [ Prerequisite Status: FAILED, Prerequisite output:
The details are:
Required amount of space(12173.691MB) is not available.]



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

To Clean Space !!!!!



export ORACLE_HOME=/u01/app/19.0.0/grid
export PATH=$ORACLE_HOME/OPatch:$PATH
echo $ORACLE_HOME





[grid@srv1 ~]$ opatch version
OPatch Version: 12.2.0.1.44

OPatch succeeded.


[grid@srv1 grid]$ du -sh .patch_storage
15G     .patch_storage
[grid@srv1 grid]$ $ORACLE_HOME/OPatch/opatch util cleanup
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation.  All rights reserved.



[grid@srv1 grid]$ du -sh .patch_storage
6.5G    .patch_storage
[grid@srv1 grid]$ $ORACLE_HOME/OPatch/opatch util cleanup




/home/grid/36916690


The OPatch being used is version 12.2.0.1.42 while the following patch(es) require higher versions:
Patch 36917416 requires OPatch version 12.2.0.1.43 or later.



export ORACLE_HOME=/u01/app/19.0.0/grid
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch


[grid@srv1 36916690]$ pwd
/home/grid/36916690
[grid@srv1 36916690]$ ls -ltr
total 144
drwxr-x---. 5 grid oinstall     62 Oct 11 11:16 36917416
drwxr-x---. 5 grid oinstall     62 Oct 11 11:17 36917397
drwxr-x---. 4 grid oinstall     48 Oct 11 11:17 36940756
drwxr-x---. 5 grid oinstall     81 Oct 11 11:17 36912597
drwxr-x---. 4 grid oinstall     48 Oct 11 11:17 36758186
-rw-r--r--. 1 grid oinstall      0 Oct 11 11:20 README.txt
drwxr-x---. 2 grid oinstall   4096 Oct 11 11:20 automation
-rw-rw-r--. 1 grid oinstall   5824 Oct 11 15:43 bundle.xml
-rw-r--r--. 1 grid oinstall 134032 Oct 14 14:01 README.html


create below commands ..

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917416
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917397
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36940756
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36912597
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36758186

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917416| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917397| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36940756| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36912597| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36758186| grep checkConflictAgainstOHWithDetail



[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917416
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_09-05-59AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"









Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917397
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_09-07-44AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36940756
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_09-09-34AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36912597
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_09-11-21AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.
[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36758186
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_09-14-27AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.


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



$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917416| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917397| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36940756| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36912597| grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36758186| grep checkConflictAgainstOHWithDetail



All Passed .. 

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917416| grep checkConflictAgainstOHWithDetail
Prereq "checkConflictAgainstOHWithDetail" passed.

[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36917397| grep checkConflictAgainstOHWithDetail
Prereq "checkConflictAgainstOHWithDetail" passed.

[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36940756| grep checkConflictAgainstOHWithDetail
Prereq "checkConflictAgainstOHWithDetail" passed.

[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36912597| grep checkConflictAgainstOHWithDetail
Prereq "checkConflictAgainstOHWithDetail" passed.

[grid@srv1 36916690]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36916690/36758186| grep checkConflictAgainstOHWithDetail
Prereq "checkConflictAgainstOHWithDetail" passed.



su -
Password:
Last login: Sat Oct 26 22:04:57 +04 2024


[root@srv1 grid]# pwd
/home/grid
[root@srv1 grid]# ls -ltr
total 132892
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Videos
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Templates
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Public
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Pictures
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Music
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Downloads
drwxr-xr-x. 2 grid oinstall         6 Jul  3  2020 Documents
drwxr-xr-x. 2 grid oinstall        40 Jul  3  2020 Desktop
-rw-r--r--. 1 grid oinstall 133535622 Apr 19  2024 p6880880_210000_Linux-x86-64.zip
drwxr-x---. 8 grid oinstall      4096 Oct 11 11:16 36916690
-rw-rw-r--. 1 grid oinstall   2537084 Oct 15 18:36 PatchSearch.xml
[root@srv1 grid]#



export ORACLE_HOME=/u01/app/19.0.0/grid
export PATH=$ORACLE_HOME/OPatch:$PATH
echo $ORACLE_HOME


[root@srv1 grid]# ls -ltr /home/grid/36916690
total 144
drwxr-x---. 5 grid oinstall     62 Oct 11 11:16 36917416
drwxr-x---. 5 grid oinstall     62 Oct 11 11:17 36917397
drwxr-x---. 4 grid oinstall     48 Oct 11 11:17 36940756
drwxr-x---. 5 grid oinstall     81 Oct 11 11:17 36912597
drwxr-x---. 4 grid oinstall     48 Oct 11 11:17 36758186
-rw-r--r--. 1 grid oinstall      0 Oct 11 11:20 README.txt
drwxr-x---. 2 grid oinstall   4096 Oct 11 11:20 automation
-rw-rw-r--. 1 grid oinstall   5824 Oct 11 15:43 bundle.xml
-rw-r--r--. 1 grid oinstall 134032 Oct 14 14:01 README.html
[root@srv1 grid]#



$ORACLE_HOME/OPatch/opatchauto apply /home/grid/36916690 -oh $ORACLE_HOME





SQL> 

set pages 50000  long 100000
spool dbms_qopatch_lsinventory.TXT
select dbms_qopatch.get_opatch_lsinventory from dual;






SQL> 

set  long 1000000 linesize 300 pagesize 300
 select xmltransform(dbms_qopatch.is_patch_installed('36917416'),dbms_qopatch.get_opatch_xslt) from dual;



[root@srv1 grid]# $ORACLE_HOME/OPatch/opatchauto apply /home/grid/36916690 -oh $ORACLE_HOME

OPatchauto session is initiated at Sun Oct 27 11:11:39 2024

System initialization log file is /u01/app/19.0.0/grid/cfgtoollogs/opatchautodb/systemconfig2024-10-27_11-11-48AM.log.

Session log file is /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/opatchauto2024-10-27_11-11-52AM.log
The id for this session is 7HX1

Executing OPatch prereq operations to verify patch applicability on home /u01/app/19.0.0/grid
Patch applicability verified successfully on home /u01/app/19.0.0/grid


Executing patch validation checks on home /u01/app/19.0.0/grid
Patch validation checks successfully completed on home /u01/app/19.0.0/grid


Performing prepatch operations on CRS - bringing down CRS service on home /u01/app/19.0.0/grid
Prepatch operation log file location: /u01/app/grid/crsdata/srv1/crsconfig/hapatch_2024-10-27_11-16-45AM.log
CRS service brought down successfully on home /u01/app/19.0.0/grid


Start applying binary patch on home /u01/app/19.0.0/grid



Binary patch applied successfully on home /u01/app/19.0.0/grid


Running rootadd_rdbms.sh on home /u01/app/19.0.0/grid
Successfully executed rootadd_rdbms.sh on home /u01/app/19.0.0/grid


Performing postpatch operations on CRS - starting CRS service on home /u01/app/19.0.0/grid
Postpatch operation log file location: /u01/app/grid/crsdata/srv1/crsconfig/hapatch_2024-10-27_11-32-03AM.log
CRS service started successfully on home /u01/app/19.0.0/grid

OPatchAuto successful.

--------------------------------Summary--------------------------------

Patching is completed successfully. Please find the summary as follows:

Host:srv1
SIHA Home:/u01/app/19.0.0/grid
Version:19.0.0.0.0
Summary:

==Following patches were SKIPPED:

Patch: /home/grid/36916690/36758186
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_11-12-18AM_1.log
Reason: /home/grid/36916690/36758186 is not required to be applied to oracle home /u01/app/19.0.0/grid


==Following patches were SUCCESSFULLY applied:

Patch: /home/grid/36916690/36912597
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_11-17-44AM_1.log

Patch: /home/grid/36916690/36917397
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_11-17-44AM_1.log

Patch: /home/grid/36916690/36917416
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_11-17-44AM_1.log

Patch: /home/grid/36916690/36940756
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-27_11-17-44AM_1.log



OPatchauto session completed at Sun Oct 27 11:34:05 2024
Time taken to complete the session 22 minutes, 18 seconds

===


[grid@srv1 ~]$ export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
[grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch util cleanup
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.44
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_11-41-28AM_1.log

Invoking utility "cleanup"
OPatch will clean up 'restore.sh,make.txt' files and 'scratch,backup' directories.
You will be still able to rollback patches after this cleanup.
Do you want to proceed? [y|n]
y


[grid@srv1 ~]$ export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch
[grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch util cleanup
Oracle Interim Patch Installer version 12.2.0.1.44
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/19.0.0/grid
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/19.0.0/grid/oraInst.loc
OPatch version    : 12.2.0.1.44
OUI version       : 12.2.0.7.0
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-27_11-41-28AM_1.log

Invoking utility "cleanup"
OPatch will clean up 'restore.sh,make.txt' files and 'scratch,backup' directories.
You will be still able to rollback patches after this cleanup.
Do you want to proceed? [y|n]
y
User Responded with: Y



Backup area for restore has been cleaned up. For a complete list of files/directories
deleted, Please refer log file.

OPatch succeeded.
[grid@srv1 ~]$
[grid@srv1 ~]$
[grid@srv1 ~]$


====
 crsctl query has releaseversion
Oracle High Availability Services release version on the local node is [19.0.0.0.0]

[grid@srv1 ~]$ crsctl query has softwareversion
Oracle High Availability Services version on the local node is [19.0.0.0.0]

[grid@srv1 ~]$ crsctl query has releasepatch
Oracle Clusterware release patch level is [760403972] and the complete list of patches [36758186 36912597 36917397 36917416 36940756 ] have been applied on the local node. The release patch string is [19.25.0.0.0].

[grid@srv1 ~]$ crsctl query has softwarepatch
Oracle Clusterware patch level on node srv1 is [760403972].
[grid@srv1 ~]$



[grid@srv1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATADISK.dg
               ONLINE  ONLINE       srv1                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       srv1                     STABLE
ora.OCRDISK.dg
               ONLINE  ONLINE       srv1                     STABLE
ora.asm
               ONLINE  ONLINE       srv1                     Started,STABLE
ora.ons
               OFFLINE OFFLINE      srv1                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       srv1                     STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       srv1                     STABLE
ora.oradb.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------
[grid@srv1 ~]$



Saturday, 26 October 2024

Patch 36582629 - GI Release Update 19.24.0.0.240716


How to Patch Oracle Grid Infrastructure 19c ?






Assistant: Download Reference for Oracle Database/GI Update, Revision, PSU, SPU(CPU), Bundle Patches, Patchsets and Base Releases (Doc ID 2118136.2)

Patch 36582629 - GI Release Update 19.24.0.0.240716

As the Grid home user: [grid@srv1 ~]$ unzip p36582629_190000_Linux-x86-64.zip inflating: 36582629/automation/bp1-rollback-inplace-automation.xml inflating: 36582629/automation/bp1-rollback-inplace-non-rolling-automation.xml inflating: 36582629/automation/messages.properties inflating: 36582629/README.txt inflating: 36582629/README.html inflating: 36582629/bundle.xml /home/grid/36582629/36587798 [grid@srv1 ~]$ echo $ORACLE_HOME /u01/app/19.0.0/grid [grid@srv1 ~]$ [grid@srv1 ~]$ export ORACLE_HOME=/u01/app/19.0.0/grid [grid@srv1 ~]$ export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36582781 $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36587798 $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36590554 $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36648174 $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36758186 [grid@srv1 ~]$ echo $ORACLE_HOME /u01/app/19.0.0/grid [grid@srv1 ~]$ export ORACLE_HOME=/u01/app/19.0.0/grid export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch grid@srv1 ~]$ ls -ld */ drwxr-x---. 8 grid oinstall 4096 Jul 13 23:20 36582629/ export ORACLE_HOME=/u01/app/19.0.0/grid export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch [grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36582781 Oracle Interim Patch Installer version 12.2.0.1.42 Copyright (c) 2024, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/19.0.0/grid Central Inventory : /u01/app/oraInventory from : /u01/app/19.0.0/grid/oraInst.loc OPatch version : 12.2.0.1.42 OUI version : 12.2.0.7.0 Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-22-05PM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded. [grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36587798 Oracle Interim Patch Installer version 12.2.0.1.42 Copyright (c) 2024, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/19.0.0/grid Central Inventory : /u01/app/oraInventory from : /u01/app/19.0.0/grid/oraInst.loc OPatch version : 12.2.0.1.42 OUI version : 12.2.0.7.0 Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-25-05PM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded. [grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36590554 Oracle Interim Patch Installer version 12.2.0.1.42 Copyright (c) 2024, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/19.0.0/grid Central Inventory : /u01/app/oraInventory from : /u01/app/19.0.0/grid/oraInst.loc OPatch version : 12.2.0.1.42 OUI version : 12.2.0.7.0 Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-25-57PM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded. [grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36648174 Oracle Interim Patch Installer version 12.2.0.1.42 Copyright (c) 2024, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/19.0.0/grid Central Inventory : /u01/app/oraInventory from : /u01/app/19.0.0/grid/oraInst.loc OPatch version : 12.2.0.1.42 OUI version : 12.2.0.7.0 Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-26-17PM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded. [grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/36582629/36758186 Oracle Interim Patch Installer version 12.2.0.1.42 Copyright (c) 2024, Oracle Corporation. All rights reserved. PREREQ session Oracle Home : /u01/app/19.0.0/grid Central Inventory : /u01/app/oraInventory from : /u01/app/19.0.0/grid/oraInst.loc OPatch version : 12.2.0.1.42 OUI version : 12.2.0.7.0 Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-26-48PM_1.log Invoking prereq "checkconflictagainstohwithdetail" Prereq "checkConflictAgainstOHWithDetail" passed. OPatch succeeded.

$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/34762026/34768569 | grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/34762026/34765931 | grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/34762026/33575402 | grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/34762026/34863894 | grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir /home/grid/34762026/34768559 | grep checkConflictAgainstOHWithDetail
$ORACLE_HOME/OPatch/opatch lsinventory|grep -i 19
Oracle Home       : /u01/app/19.0.0/grid
   from           : /u01/app/19.0.0/grid/oraInst.loc
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_21-39-12PM_1.log
Lsinventory Output file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2024-10-26_21-39-12PM.txt
Oracle Grid Infrastructure 19c                                       19.0.0.0.0
Patch description:  "TOMCAT RELEASE UPDATE 19.0.0.0.0 (34863894)"
     32625073, 33121445, 33655429, 33846688, 34300543, 34519419, 34816344
Patch description:  "ACFS RELEASE UPDATE 19.18.0.0.0 (34768569)"
   Created on 19 Dec 2022, 00:41:48 hrs PST8PDT





[grid@srv1 ~]$ which opatchauto
/u01/app/19.0.0/grid/OPatch/opatchauto


To patch only the Grid home:

# opatchauto apply /home/grid/36582629 -oh /u01/app/19.0.0/grid




***********  as root !!!

export ORACLE_HOME=/u01/app/19.0.0/grid
export PATH=$ORACLE_HOME/OPatch:$PATH
echo $ORACLE_HOME
/u01/app/19.0.0/grid


[grid@srv1 ~]$ su -
Password:

[root@srv1 ~]# export ORACLE_HOME=/u01/app/19.0.0/grid
[root@srv1 ~]# export PATH=$ORACLE_HOME/OPatch:$PATH




$ORACLE_HOME/OPatch/opatchauto -help

Invalid current directory.  Please run opatchauto from other than '/root' or '/' directory.
And check if the home owner user has write permission set for the current directory.
opatchauto returns with error code = 2   <<<<

change the dir 

[root@srv1 ~]# cd /home/grid

$ORACLE_HOME/OPatch/opatchauto apply /home/grid/36582629 -oh $ORACLE_HOME



[root@srv1 ~]# cd /home/grid
[root@srv1 grid]#
[root@srv1 grid]# $ORACLE_HOME/OPatch/opatchauto apply /home/grid/36582629 -oh $ORACLE_HOME

OPatchauto session is initiated at Sat Oct 26 21:47:11 2024

System initialization log file is /u01/app/19.0.0/grid/cfgtoollogs/opatchautodb/systemconfig2024-10-26_09-47-21PM.log.

Session log file is /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/opatchauto2024-10-26_09-47-26PM.log
The id for this session is 8TYG

Executing OPatch prereq operations to verify patch applicability on home /u01/app/19.0.0/grid
Patch applicability verified successfully on home /u01/app/19.0.0/grid


Executing patch validation checks on home /u01/app/19.0.0/grid
Patch validation checks successfully completed on home /u01/app/19.0.0/grid


Performing prepatch operations on CRS - bringing down CRS service on home /u01/app/19.0.0/grid
Prepatch operation log file location: /u01/app/grid/crsdata/srv1/crsconfig/hapatch_2024-10-26_09-49-47PM.log
CRS service brought down successfully on home /u01/app/19.0.0/grid


Start applying binary patch on home /u01/app/19.0.0/grid




Binary patch applied successfully on home /u01/app/19.0.0/grid


Running rootadd_rdbms.sh on home /u01/app/19.0.0/grid
Successfully executed rootadd_rdbms.sh on home /u01/app/19.0.0/grid


Performing postpatch operations on CRS - starting CRS service on home /u01/app/19.0.0/grid

Postpatch operation log file location: /u01/app/grid/crsdata/srv1/crsconfig/hapatch_2024-10-26_10-03-06PM.log
CRS service started successfully on home /u01/app/19.0.0/grid

OPatchAuto successful.

--------------------------------Summary--------------------------------

Patching is completed successfully. Please find the summary as follows:

Host:srv1
SIHA Home:/u01/app/19.0.0/grid
Version:19.0.0.0.0
Summary:

==Following patches were SUCCESSFULLY applied:

Patch: /home/grid/36582629/36582781
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-26_21-50-44PM_1.log

Patch: /home/grid/36582629/36587798
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-26_21-50-44PM_1.log

Patch: /home/grid/36582629/36590554
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-26_21-50-44PM_1.log

Patch: /home/grid/36582629/36648174
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-26_21-50-44PM_1.log

Patch: /home/grid/36582629/36758186
Log: /u01/app/19.0.0/grid/cfgtoollogs/opatchauto/core/opatch/opatch2024-10-26_21-50-44PM_1.log



OPatchauto session completed at Sat Oct 26 22:04:57 2024
Time taken to complete the session 17 minutes, 36 seconds
[root@srv1 grid]#
[root@srv1 grid]#
[root@srv1 grid]#
[root@srv1 grid]#
[root@srv1 grid]#

[grid@srv1 ~]$ export PATH=$ORACLE_HOME/OPatch:$PATH
[grid@srv1 ~]$ opatch lsinventory | grep -E "(^Patch.*applied)|(^Sub-patch)"
Patch  36758186     : applied on Sat Oct 26 22:02:01 GST 2024
Patch  36648174     : applied on Sat Oct 26 22:01:48 GST 2024
Patch  36590554     : applied on Sat Oct 26 22:01:05 GST 2024
Patch  36587798     : applied on Sat Oct 26 22:00:17 GST 2024
Patch  36582781     : applied on Sat Oct 26 21:55:32 GST 2024
[grid@srv1 ~]$




$ORACLE_HOME/OPatch/opatch lsinventory|grep -i 19.18



$ORACLE_HOME/OPatch/opatch lsinventory|grep -i 19.
Oracle Home       : /u01/app/19.0.0/grid
   from           : /u01/app/19.0.0/grid/oraInst.loc
Log file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/opatch2024-10-26_22-11-32PM_1.log
Lsinventory Output file location : /u01/app/19.0.0/grid/cfgtoollogs/opatch/lsinv/lsinventory2024-10-26_22-11-32PM.txt
Oracle Grid Infrastructure 19c                                       19.0.0.0.0
Patch description:  "DBWLM RELEASE UPDATE 19.0.0.0.0 (36758186)"
Patch description:  "TOMCAT RELEASE UPDATE 19.0.0.0.0 (36648174)"
     32625073, 33121445, 33655429, 33846688, 34300543, 34519419, 34816344
Patch description:  "ACFS RELEASE UPDATE 19.24.0.0.0 (36590554)"


$ORACLE_HOME/OPatch/opatch lsinventory|grep -i "Patch description"



[grid@srv1 ~]$ $ORACLE_HOME/OPatch/opatch lsinventory|grep -i "Patch description"
Patch description:  "DBWLM RELEASE UPDATE 19.0.0.0.0 (36758186)"
Patch description:  "TOMCAT RELEASE UPDATE 19.0.0.0.0 (36648174)"
Patch description:  "ACFS RELEASE UPDATE 19.24.0.0.0 (36590554)"
Patch description:  "OCW RELEASE UPDATE 19.24.0.0.0 (36587798)"
Patch description:  "Database Release Update : 19.24.0.0.240716 (36582781)"
[grid@srv1 ~]$



[grid@srv1 ~]$ opatch lspatches
36758186;DBWLM RELEASE UPDATE 19.0.0.0.0 (36758186)
36648174;TOMCAT RELEASE UPDATE 19.0.0.0.0 (36648174)
36590554;ACFS RELEASE UPDATE 19.24.0.0.0 (36590554)
36587798;OCW RELEASE UPDATE 19.24.0.0.0 (36587798)
36582781;Database Release Update : 19.24.0.0.240716 (36582781)

OPatch succeeded.

crsctl query has releaseversion
    Lists the Oracle Clusterware release version

  crsctl query has softwareversion
    Lists the version of Oracle Clusterware software installed on the local node

  crsctl query has releasepatch
     Lists the Oracle Clusterware release patch level

  crsctl query has softwarepatch
     Lists the patch level of Oracle Clusterware software installed on the local host



crsctl query has releaseversion
crsctl query has softwareversion
crsctl query has releasepatch
crsctl query has softwarepatch


[grid@srv1 ~]$ crsctl query has releaseversion
Oracle High Availability Services release version on the local node is [19.0.0.0.0]

[grid@srv1 ~]$ crsctl query has softwareversion
Oracle High Availability Services version on the local node is [19.0.0.0.0]

[grid@srv1 ~]$ crsctl query has releasepatch
Oracle Clusterware release patch level is [3669234883] and the complete list of patches [36582781 36587798 36590554 36648174 36758186 ] have been applied on the local node. The release patch string is [19.24.0.0.0].

[grid@srv1 ~]$ crsctl query has softwarepatch
Oracle Clusterware patch level on node srv1 is [3669234883].



[grid@srv1 ~]$ crsctl status res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATADISK.dg
               ONLINE  ONLINE       srv1                     STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       srv1                     STABLE
ora.OCRDISK.dg
               ONLINE  ONLINE       srv1                     STABLE
ora.asm
               ONLINE  ONLINE       srv1                     Started,STABLE
ora.ons
               OFFLINE OFFLINE      srv1                     STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       srv1                     STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       srv1                     STABLE
ora.oradb.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
--------------------------------------------------------------------------------



 crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'srv1'
CRS-2673: Attempting to stop 'ora.OCRDISK.dg' on 'srv1'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'srv1'
CRS-2677: Stop of 'ora.OCRDISK.dg' on 'srv1' succeeded
CRS-2673: Attempting to stop 'ora.DATADISK.dg' on 'srv1'
CRS-2677: Stop of 'ora.DATADISK.dg' on 'srv1' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'srv1'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'srv1' succeeded
CRS-2677: Stop of 'ora.asm' on 'srv1' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'srv1'
CRS-2677: Stop of 'ora.evmd' on 'srv1' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'srv1'
CRS-2677: Stop of 'ora.cssd' on 'srv1' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'srv1' has completed
CRS-4133: Oracle High Availability Services has been stopped.
[grid@srv1 ~]$







Sunday, 20 October 2024

Oracle sql KEEP clause


Oracle sql KEEP clause 


select 
deptno,
min(sal) ,
min(empno) keep (dense_rank first order by sal ) empnomin,
max(sal) ,
max(empno) keep (dense_rank last order by sal ) empnomax
from emp
group by deptno;



   DEPTNO   MIN(SAL)   EMPNOMIN   MAX(SAL)   EMPNOMAX
---------- ---------- ---------- ---------- ----------
        10       1300       7934       5000       7839
        20        800       7369       3000       7902
        30        950       7900       2850       7698


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

select * from emp

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

14 rows selected.






CREATE TABLE dense_rank_demo (
    col VARCHAR2(10) NOT NULL
);

INSERT ALL 
    INTO dense_rank_demo(col) VALUES('A')
    INTO dense_rank_demo(col) VALUES('A')
    INTO dense_rank_demo(col) VALUES('B')
    INTO dense_rank_demo(col) VALUES('C')
    INTO dense_rank_demo(col) VALUES('C')
    INTO dense_rank_demo(col) VALUES('C')
    INTO dense_rank_demo(col) VALUES('D')
SELECT 1 FROM dual; 

commit ;



SQL> select * from dense_rank_demo;

COL
----------
A
A
B
C
C
C
D




SELECT
	col,
	DENSE_RANK () OVER ( 
		ORDER BY col ) 
	rank
FROM
	dense_rank_demo;



COL              RANK
---------- ----------
A                   1
A                   1
B                   2
C                   3
C                   3
C                   3
D                   4

7 rows selected.




Monday, 14 October 2024

Oracle Instances memory consumption on Linux



 from https://www.ludovicocaldara.net/dba/real-memory-usage-on-linux/

 cat mem.sh
#!/bin/bash

username=`whoami`
username=oracle
sids=`ps -eaf | grep "^$username" | grep pmon | grep -v " grep "  | awk '{print substr($NF,10)}'`


total=0
for sid in $sids ; do
        pids=`ps -eaf | grep "^$username" | grep -- "$sid" | grep -v " grep " | awk '{print $2}'`
        mem=`pmap $pids 2>&1 | grep "K " | sort | awk '{print $1 " " substr($2,1,length($2)-1)}' | uniq | awk ' BEGIN { sum=0 } { sum+=$2} END {print sum}' `

        echo "$sid : $mem"
        total=`expr $total + $mem`
done

echo "total :  $total"




./mem.sh
ugaryd : 6790308
ugary : 9707680
irac1 : 23071180
total :  39569168

Patch 36582781 - Database Release Update 19.24.0.0.240716


Patch 36582781 - Database Release Update 19.24.0.0.240716 ....

Oracle Database 19c Proactive Patch Information (Doc ID 2521164.1)

Patch 36582781 - Database Release Update 19.24.0.0.240716

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

Patch 36582781: DATABASE RELEASE UPDATE 19.24.0.0.0
 
Last Updated	Jul 16, 2024 6:06 AM (2+ months ago)

Product	Oracle Database - Enterprise Edition
(More...)
Release	Oracle Database 19.0.0.0.0
Platform	Linux x86-64


Size	1.8 GB   file size 




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


[oracle@srv1 36582781]$ pwd
/home/oracle/36582781

[oracle@srv1 36582781]$ export PATH=$ORACLE_HOME/OPatch:$PATH

[oracle@srv1 36582781]$ opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-10-14_07-50-20AM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.


[oracle@srv1 36582781]$


[oracle@srv1 36582781]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Oct 14 07:54:15 2024
Version 19.23.0.0.0

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


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.23.0.0.0

SQL> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.23.0.0.0
[oracle@srv1 36582781]$ pwd
/home/oracle/36582781
[oracle@srv1 36582781]$ opatch apply
Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-10-14_07-55-29AM_1.log

Verifying environment and performing prerequisite checks...

--------------------------------------------------------------------------------
Start OOP by Prereq process.
Launch OOP...

Oracle Interim Patch Installer version 12.2.0.1.42
Copyright (c) 2024, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/19.0.0/db_1
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19.0.0/db_1/oraInst.loc
OPatch version    : 12.2.0.1.42
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-10-14_07-58-08AM_1.log

Verifying environment and performing prerequisite checks...




OPatch continues with these patches:   36582781

Do you want to proceed? [y|n]
Could not recognize input. Please re-enter.
y
User Responded with: Y
All checks passed.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19.0.0/db_1')


Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '36582781' to OH '/u01/app/oracle/product/19.0.0/db_1'
ApplySession: Optional component(s) [ oracle.network.gsm, 19.0.0.0.0 ] , [ oracle.crypto.rsf, 19.0.0.0.0 ] , [ oracle.pg4appc, 19.0.0.0.0 ] , [ oracle.pg4mq, 19.0.0.0.0 ] , [ oracle.precomp.companion, 19.0.0.0.0 ] , [ oracle.rdbms.ic, 19.0.0.0.0 ] , [ oracle.rdbms.tg4db2, 19.0.0.0.0 ] , [ oracle.tfa, 19.0.0.0.0 ] , [ oracle.net.cman, 19.0.0.0.0 ] , [ oracle.ons.cclient, 19.0.0.0.0 ] , [ oracle.rdbms.tg4ifmx, 19.0.0.0.0 ] , [ oracle.options.olap, 19.0.0.0.0 ] , [ oracle.rdbms.tg4msql, 19.0.0.0.0 ] , [ oracle.sdo.companion, 19.0.0.0.0 ] , [ oracle.ons.eons.bwcompat, 19.0.0.0.0 ] , [ oracle.network.cman, 19.0.0.0.0 ] , [ oracle.rdbms.tg4sybs, 19.0.0.0.0 ] , [ oracle.rdbms.tg4tera, 19.0.0.0.0 ] , [ oracle.xdk.companion, 19.0.0.0.0 ] , [ oracle.options.olap.api, 19.0.0.0.0 ] , [ oracle.oid.client, 19.0.0.0.0 ] , [ oracle.jdk, 1.8.0.191.0 ]  not present in the Oracle Home or a higher version is found.

Patching component oracle.rdbms, 19.0.0.0.0...


Patching component oracle.rdbms.util, 19.0.0.0.0...

Patching component oracle.rdbms.rsf, 19.0.0.0.0...

Patching component oracle.assistants.acf, 19.0.0.0.0...

Patching component oracle.assistants.deconfig, 19.0.0.0.0...

Patching component oracle.assistants.server, 19.0.0.0.0...

Patching component oracle.blaslapack, 19.0.0.0.0...

Patching component oracle.buildtools.rsf, 19.0.0.0.0...

Patching component oracle.ctx, 19.0.0.0.0...

Patching component oracle.dbdev, 19.0.0.0.0...

Patching component oracle.dbjava.ic, 19.0.0.0.0...

Patching component oracle.dbjava.jdbc, 19.0.0.0.0...

Patching component oracle.dbjava.ucp, 19.0.0.0.0...

Patching component oracle.duma, 19.0.0.0.0...

Patching component oracle.javavm.client, 19.0.0.0.0...

Patching component oracle.ldap.owm, 19.0.0.0.0...

Patching component oracle.ldap.rsf, 19.0.0.0.0...

Patching component oracle.ldap.security.osdt, 19.0.0.0.0...

Patching component oracle.marvel, 19.0.0.0.0...

Patching component oracle.network.rsf, 19.0.0.0.0...

Patching component oracle.odbc.ic, 19.0.0.0.0...

Patching component oracle.ons, 19.0.0.0.0...

Patching component oracle.ons.ic, 19.0.0.0.0...

Patching component oracle.oracore.rsf, 19.0.0.0.0...

Patching component oracle.perlint, 5.28.1.0.0...

Patching component oracle.precomp.common.core, 19.0.0.0.0...

Patching component oracle.nlsrtl.rsf.core, 19.0.0.0.0...

Patching component oracle.nlsrtl.rsf.ic, 19.0.0.0.0...

Patching component oracle.precomp.rsf, 19.0.0.0.0...

Patching component oracle.rdbms.crs, 19.0.0.0.0...

Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...

Patching component oracle.rdbms.deconfig, 19.0.0.0.0...

Patching component oracle.rdbms.oci, 19.0.0.0.0...

Patching component oracle.rdbms.rsf.ic, 19.0.0.0.0...

Patching component oracle.rdbms.scheduler, 19.0.0.0.0...

Patching component oracle.rhp.db, 19.0.0.0.0...

Patching component oracle.rsf, 19.0.0.0.0...

Patching component oracle.sdo, 19.0.0.0.0...

Patching component oracle.sdo.locator.jrf, 19.0.0.0.0...

Patching component oracle.sqlplus, 19.0.0.0.0...

Patching component oracle.sqlplus.ic, 19.0.0.0.0...

Patching component oracle.wwg.plsql, 19.0.0.0.0...

Patching component oracle.xdk.rsf, 19.0.0.0.0...

Patching component oracle.ovm, 19.0.0.0.0...

Patching component oracle.rdbms.drdaas, 19.0.0.0.0...

Patching component oracle.oraolap, 19.0.0.0.0...

Patching component oracle.rdbms.dv, 19.0.0.0.0...

Patching component oracle.nlsrtl.rsf.lbuilder, 19.0.0.0.0...

Patching component oracle.rdbms.hsodbc, 19.0.0.0.0...

Patching component oracle.rdbms.hs_common, 19.0.0.0.0...

Patching component oracle.rdbms.install.plugins, 19.0.0.0.0...

Patching component oracle.install.deinstalltool, 19.0.0.0.0...

Patching component oracle.oraolap.api, 19.0.0.0.0...

Patching component oracle.xdk.parser.java, 19.0.0.0.0...

Patching component oracle.mgw.common, 19.0.0.0.0...

Patching component oracle.network.listener, 19.0.0.0.0...

Patching component oracle.xdk.xquery, 19.0.0.0.0...

Patching component oracle.ldap.ssl, 19.0.0.0.0...

Patching component oracle.rdbms.rman, 19.0.0.0.0...

Patching component oracle.odbc, 19.0.0.0.0...

Patching component oracle.sdo.locator, 19.0.0.0.0...

Patching component oracle.ldap.client, 19.0.0.0.0...

Patching component oracle.rdbms.install.common, 19.0.0.0.0...

Patching component oracle.ctx.atg, 19.0.0.0.0...

Patching component oracle.rdbms.dm, 19.0.0.0.0...

Patching component oracle.oraolap.dbscripts, 19.0.0.0.0...

Patching component oracle.xdk, 19.0.0.0.0...

Patching component oracle.javavm.server, 19.0.0.0.0...

Patching component oracle.dbtoolslistener, 19.0.0.0.0...

Patching component oracle.rdbms.locator, 19.0.0.0.0...

Patching component oracle.ctx.rsf, 19.0.0.0.0...

Patching component oracle.ldap.rsf.ic, 19.0.0.0.0...

Patching component oracle.network.client, 19.0.0.0.0...

Patching component oracle.rdbms.rat, 19.0.0.0.0...

Patching component oracle.nlsrtl.rsf, 19.0.0.0.0...

Patching component oracle.rdbms.lbac, 19.0.0.0.0...

Patching component oracle.precomp.common, 19.0.0.0.0...

Patching component oracle.precomp.lang, 19.0.0.0.0...

Patching component oracle.jdk, 1.8.0.201.0...
Patch 36582781 successfully applied.
Sub-set patch [36233263] has become inactive due to the application of a super-set patch [36582781].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /u01/app/oracle/product/19.0.0/db_1/cfgtoollogs/opatch/opatch2024-10-14_07-58-08AM_1.log

OPatch succeeded.



[oracle@srv1 36582781]$
[oracle@srv1 36582781]$



**********************************************************************************************
show pdbs;

SQL> alter pluggable database all open;

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



 ./datapatch -sanity_checks
SQL Patching sanity checks version 19.24.0.0.0 on Mon 14 Oct 2024 08:16:05 AM +04
Copyright (c) 2021, 2024, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sanity_checks_20241014_081605_9239/sanity_checks_20241014_081605_9239.log

Running checks
JSON report generated in /u01/app/oracle/cfgtoollogs/sqlpatch/sanity_checks_20241014_081605_9239/sqlpatch_sanity_checks_summary.json file
Checks completed. Printing report:

Check: Database component status - OK
Check: PDB Violations - OK
Check: Invalid System Objects - OK
Check: Tablespace Status - OK
Check: Backup jobs - OK
Check: Temp file exists - OK
Check: Temp file online - OK
Check: Data Pump running - OK
Check: Container status - OK
Check: Oracle Database Keystore - OK
Check: Dictionary statistics gathering - OK
Check: Scheduled Jobs - OK
Check: GoldenGate triggers - OK
Check: Logminer DDL triggers - OK
Check: Check sys public grants - OK
Check: Statistics gathering running - OK
Check: Optim dictionary upgrade parameter - OK
Check: Symlinks on oracle home path - OK
Check: Central Inventory - OK
Check: Queryable Inventory dba directories - OK
Check: Queryable Inventory locks - OK
Check: Queryable Inventory package - OK
Check: Queryable Inventory external table - OK
Check: Imperva processes - OK
Check: Guardium processes - OK
Check: Locale - OK

SQL Patching sanity checks completed on Mon 14 Oct 2024 08:17:23 AM +04
[oracle@srv1 OPatch]$


**********************************************************************************************
show pdbs;

SQL> alter pluggable database all open;

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

[oracle@srv1 OPatch]$ ./datapatch -verbose
SQL Patching tool version 19.24.0.0.0 Production on Mon Oct 14 08:18:27 2024
Copyright (c) 2012, 2024, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_10162_2024_10_14_08_18_27/sqlpatch_invocation.log

Connecting to database...OK
Gathering database info...done

Note:  Datapatch will only apply or rollback SQL fixes for PDBs
       that are in an open state, no patches will be applied to closed PDBs.
       Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
       (Doc ID 1585822.1)

Bootstrapping registry and package to current versions...done
Determining current state...done

Current state of interim SQL patches:
Interim patch 31219897 (OJVM RELEASE UPDATE: 19.8.0.0.200714 (31219897)):
  Binary registry: Installed
  PDB CDB$ROOT: Applied successfully on 10-SEP-20 12.34.31.168250 PM
  PDB PDB$SEED: Applied successfully on 10-SEP-20 12.34.40.711871 PM
  PDB PDB1: Applied successfully on 10-SEP-20 12.41.43.472665 PM

Current state of release update SQL patches:
  Binary registry:
    19.24.0.0.0 Release_Update 240627235157: Installed
  PDB CDB$ROOT:
    Applied 19.23.0.0.0 Release_Update 240406004238 successfully on 20-APR-24 10.05.35.931655 PM
  PDB PDB$SEED:
    Applied 19.23.0.0.0 Release_Update 240406004238 successfully on 20-APR-24 10.09.18.365114 PM
  PDB PDB1:
    Applied 19.23.0.0.0 Release_Update 240406004238 successfully on 20-APR-24 10.09.18.242487 PM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT PDB$SEED PDB1
    No interim patches need to be rolled back
    Patch 36582781 (Database Release Update : 19.24.0.0.240716 (36582781)):
      Apply from 19.23.0.0.0 Release_Update 240406004238 to 19.24.0.0.0 Release_Update 240627235157
    No interim patches need to be applied


Installing patches...



Patch installation complete.  Total patches installed: 3

Validating logfiles...done
Patch 36582781 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36582781/25751445/36582781_apply_ORADB_CDBROOT_2024Oct14_08_22_11.log (no errors)
Patch 36582781 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36582781/25751445/36582781_apply_ORADB_PDBSEED_2024Oct14_08_23_53.log (no errors)
Patch 36582781 apply (pdb PDB1): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/36582781/25751445/36582781_apply_ORADB_PDB1_2024Oct14_08_23_53.log (no errors)
SQL Patching tool complete on Mon Oct 14 08:26:00 2024
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$
[oracle@srv1 OPatch]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Oct 14 08:27:39 2024
Version 19.24.0.0.0 -------------------------------------------------------- 



show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
SQL>



du -sh */
3.8G    36582781/
12K     Desktop/
0       Documents/
3.8G    Downloads/
0       Music/
0       Pictures/
0       Public/
0       Templates/
0       Videos/
[oracle@srv1 ~]$ rm -rf 36582781/

Tuesday, 24 September 2024

Sql plan changed !!!

unstable plans 

  
set lines 200 pages 9999
col execs for 999,999,999
col min_etime for 999,999.99
col max_etime for 999,999.99
col avg_etime for 999,999.999
col avg_lio for 999,999,999.9
col norm_stddev for 999,999.9999
col begin_interval_time for a30
col node for 99999
break on plan_hash_value on startup_time skip 1
select * from (
select sql_id, sum(execs), min(avg_etime) min_etime, max(avg_etime) max_etime, stddev_etime/min(avg_etime) norm_stddev
from (
select sql_id, plan_hash_value, execs, avg_etime,
stddev(avg_etime) over (partition by sql_id) stddev_etime
from (
select sql_id, plan_hash_value,
sum(nvl(executions_delta,0)) execs,
(sum(elapsed_time_delta)/decode(sum(nvl(executions_delta,0)),0,1,sum(executions_delta))/1000000) avg_etime
-- sum((buffer_gets_delta/decode(nvl(buffer_gets_delta,0),0,1,executions_delta))) avg_lio
from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT SS
where ss.snap_id = S.snap_id
and ss.instance_number = S.instance_number
and executions_delta > 0
group by sql_id, plan_hash_value
)
)
group by sql_id, stddev_etime
)
where norm_stddev > nvl(to_number('&min_stddev'),2)
and max_etime > nvl(to_number('&min_etime'),.1)
order by norm_stddev
/
  
  
  -- whats_changed_c.sql
  
DEF days_of_history_accessed = '5';
DEF captured_at_least_x_times = '1';
DEF captured_at_least_x_days_apart = '5';
DEF med_elap_microsecs_threshold = '1e4';
DEF min_slope_threshold = '0.1';
DEF max_num_rows = '20';
 
SET lin 300 ver OFF;
set linesize 500
COL row_n 			  format A2 	 HEA '#';
COL change			  format A13	 								  justify left;
COL slope 			  format 9999.99 HEA 'SLOPE'  					  justify right;
COL pctdbtim    	  format 99.99 	 HEA 'Total Elapsed|% DB Time'    justify right;
COL med_secs_per_exec format a15 	 HEA 'Median Secs|Per Exec'  	  justify right;
COL std_secs_per_exec format a15 	 HEA 'Std Dev Secs|Per Exec'   	  justify right;
COL avg_secs_per_exec format a15 	 HEA 'Avg Secs|Per Exec'  		  justify right;
COL min_secs_per_exec format a15 	 HEA 'Min Secs|Per Exec'  		  justify right;
COL max_secs_per_exec format a15 	 HEA 'Max Secs|Per Exec'  		  justify right;
COL plans 			  format 9999 									  justify right;
COL sql_text_80 	  format A80 									  justify left;
 
PRO SQL Statements with "Elapsed Time per Execution" changing over time
 
WITH
  per_time AS
  (
    SELECT
      h.dbid,
      h.sql_id,
      SYSDATE                   - CAST(s.end_interval_time AS DATE) days_ago,
      SUM(h.elapsed_time_delta) / SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta))  time_per_exec,
      --SUM(h.elapsed_time_delta)  time_per_exec,
      SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta)) execs
    FROM
      dba_hist_sqlstat h,
      dba_hist_snapshot s
    WHERE s.snap_id                  = h.snap_id
    AND s.dbid                     = h.dbid
    AND s.instance_number          = h.instance_number
    AND h.parsing_schema_name NOT IN ('SYS','SYSTEM','SYSTEM2','DBSNMP')
 	AND h.executions_delta           > 0
    AND CAST(s.end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
    GROUP BY
      h.dbid,
      h.sql_id,
      SYSDATE - CAST(s.end_interval_time AS DATE)
	HAVING
	  SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta)) >= 1
  )
  ,
  db_time AS
  (
    SELECT
      tdbtim
    FROM
      (
      (
        SELECT
          e.stat_name ,
          (e.value - NVL(b.value,0)) value
        FROM
          dba_hist_sys_time_model b ,
          dba_hist_sys_time_model e
        WHERE
          e.dbid              = b.dbid
        AND e.instance_number = b.instance_number
        AND e.snap_id         =
          (
            SELECT
              MAX(snap_id)
            FROM
              dba_hist_snapshot
            WHERE
              CAST(end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
          )
        AND b.snap_id =
          (
            SELECT
              MIN(snap_id)
            FROM
              dba_hist_snapshot
            WHERE
              CAST(end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
          )
        AND b.stat_id    = e.stat_id
        AND e.stat_name IN ('DB time','DB CPU',
          'background elapsed time','background cpu time')
      )
      pivot (SUM(value) FOR stat_name IN ('DB time' tdbtim)) )
  )
  ,
  sql_dbt AS
  (
    SELECT
      h.sql_id,
      ROUND(h.time_per_exec*100/d.tdbtim,2) pctdbtim
    FROM
      (
        SELECT
          sql_id,
          SUM(time_per_exec*execs) time_per_exec
        FROM
          per_time
        GROUP BY
          sql_id
      )
      h,
      db_time d
  )
  ,
  avg_time AS
  (
    SELECT
      dbid,
      sql_id,
      MEDIAN(time_per_exec) med_time_per_exec,
      STDDEV(time_per_exec) std_time_per_exec,
      AVG(time_per_exec) avg_time_per_exec,
      MIN(time_per_exec) min_time_per_exec,
      MAX(time_per_exec) max_time_per_exec
    FROM
      per_time
    GROUP BY
      dbid,
      sql_id
    HAVING
      COUNT(*) >= &&captured_at_least_x_times.
      --AND MAX(days_ago) - MIN(days_ago) >=
      -- &&captured_at_least_x_days_apart.
    AND MEDIAN(time_per_exec) >   &&med_elap_microsecs_threshold.
  )
  ,
  time_over_median AS
  (
    SELECT
      h.dbid,
      h.sql_id,
      h.days_ago,
      (h.time_per_exec / a.med_time_per_exec) time_per_exec_over_med,
      a.med_time_per_exec,
      a.std_time_per_exec,
      a.avg_time_per_exec,
      a.min_time_per_exec,
      a.max_time_per_exec
    FROM
      per_time h,
      avg_time a
    WHERE
      a.sql_id = h.sql_id
  )
  ,
  ranked AS
  (
    SELECT
      RANK () OVER (ORDER BY ABS(REGR_SLOPE(t.time_per_exec_over_med,t.days_ago)) DESC) rank_num,
      t.dbid,
      t.sql_id,
      CASE
        WHEN REGR_SLOPE(t.time_per_exec_over_med, t.days_ago) > 0
        THEN 'IMPROVING'
        ELSE 'REGRESSING'
      END change,
      ROUND(REGR_SLOPE(t.time_per_exec_over_med, t.days_ago), 3)
      slope,
      ROUND(AVG(t.med_time_per_exec)/1e6, 3) med_secs_per_exec,
      ROUND(AVG(t.std_time_per_exec)/1e6, 3) std_secs_per_exec,
      ROUND(AVG(t.avg_time_per_exec)/1e6, 3) avg_secs_per_exec,
      ROUND(MIN(t.min_time_per_exec)/1e6, 3) min_secs_per_exec,
      ROUND(MAX(t.max_time_per_exec)/1e6, 3) max_secs_per_exec
    FROM
      time_over_median t
    GROUP BY
      t.dbid,
      t.sql_id
    HAVING
      ABS(REGR_SLOPE(t.time_per_exec_over_med, t.days_ago)) > &&min_slope_threshold.
  )
SELECT
  row_n,
  r.sql_id,
  change,
  slope,
  s.pctdbtim,
  lpad(med_secs_per_exec,15,' ') med_secs_per_exec,
  lpad(std_secs_per_exec,15,' ') std_secs_per_exec,
  lpad(avg_secs_per_exec,15,' ') avg_secs_per_exec,
  lpad(min_secs_per_exec,15,' ') min_secs_per_exec,
  lpad(max_secs_per_exec,15,' ') max_secs_per_exec,
  plans,
  sql_text_80
FROM
  (
    SELECT
      LPAD(ROWNUM, 2) row_n,
      r.sql_id,
      r.change,
      --TO_CHAR(r.slope, '990.000MI') slope,
      ROUND(r.slope,2) slope,
      --TO_CHAR(s.pctdbtim,'99.9999') ela_pct_dbtime,
      TO_CHAR(r.med_secs_per_exec, '999,990.000') med_secs_per_exec,
      TO_CHAR(r.std_secs_per_exec, '999,990.000') std_secs_per_exec,
      TO_CHAR(r.avg_secs_per_exec, '999,990.000') avg_secs_per_exec,
      TO_CHAR(r.min_secs_per_exec, '999,990.000') min_secs_per_exec,
      TO_CHAR(r.max_secs_per_exec, '999,990.000') max_secs_per_exec,
      (
        SELECT
          COUNT(DISTINCT p.plan_hash_value)
        FROM
          dba_hist_sql_plan p
        WHERE
          p.dbid     = r.dbid
        AND p.sql_id = r.sql_id
      )
      plans,
      REPLACE(
      (
        SELECT distinct
          sys.DBMS_LOB.SUBSTR(s.sql_text, 80)
        FROM
          dba_hist_sqltext s
        WHERE
          s.dbid     = r.dbid
        AND s.sql_id = r.sql_id
      )
      , CHR(10)) sql_text_80
    FROM
      ranked r
    WHERE
      r.rank_num <= &&max_num_rows.
    ORDER BY
      r.rank_num
  )
  r,
  sql_dbt s
WHERE
  r.sql_id = s.sql_id
ORDER BY
  row_n
/






                                 Total Elapsed     Median Secs    Std Dev Secs        Avg Secs        Min Secs        Max Secs
#  SQL_ID        CHANGE           SLOPE     % DB Time        Per Exec        Per Exec        Per Exec        Per Exec        Per Exec PLANS SQL_TEXT_80
-- ------------- ------------- -------- ------------- --------------- --------------- --------------- --------------- --------------- ----- --------------------------------------------------------------------------------
 1 00nxwgnnnhd9z REGRESSING        -.62           .15         151.788         140.202         222.579         131.888         384.062  2 SELECT AUDITSIGNATURE,SEQUENCEGENERATORPOOLNAME,SEQUENCEGENERATORID,SEQUENCENUMB
 2 02jrgb8ppzbpx IMPROVING          .13           .32         262.992         168.498         285.982          53.514         523.788  0 call FTRESS_FT.purge_exp_sessions (  )








COL force_matching_signature format 999999999999999999999999 HEA 'FORCE_MATCHING'  justify right;

WITH
  per_time AS
  (
    SELECT
      h.dbid,
      --h.sql_id,
      h.force_matching_signature,
      SYSDATE   - CAST(s.end_interval_time AS DATE) days_ago,
      SUM(h.elapsed_time_delta) / SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta))  time_per_exec,
      --SUM(h.elapsed_time_delta)  time_per_exec,
      SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta)) execs
    FROM
      dba_hist_sqlstat h,
      dba_hist_snapshot s
    WHERE
      h.executions_delta           > 0
    AND s.snap_id                  = h.snap_id
    AND s.dbid                     = h.dbid
    AND s.instance_number          = h.instance_number
    AND h.parsing_schema_name NOT IN ('SYS','SYSTEM','SYSTEM2', 'DBSNMP')
    AND CAST(s.end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
    GROUP BY
      h.dbid,
      --h.sql_id,
      h.force_matching_signature,
      SYSDATE - CAST(s.end_interval_time AS DATE)
	HAVING
	  SUM(decode(h.executions_delta,0,0.00000001,h.executions_delta)) >= 1
  )
  ,
  db_time AS
  (
    SELECT
      tdbtim,
      tdbcpu,
      tbgtim,
      tbgcpu
    FROM
      (
      (
        SELECT
          e.stat_name ,
          (e.value - NVL(b.value,0)) value
        FROM
          dba_hist_sys_time_model b ,
          dba_hist_sys_time_model e
        WHERE
          e.dbid              = b.dbid
        AND e.instance_number = b.instance_number
        AND e.snap_id         =
          (
            SELECT
              MAX(snap_id)
            FROM
              dba_hist_snapshot
            WHERE
              CAST(end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
          )
        AND b.snap_id =
          (
            SELECT
              MIN(snap_id)
            FROM
              dba_hist_snapshot
            WHERE
              CAST(end_interval_time AS DATE) > SYSDATE - &&days_of_history_accessed.
          )
        AND b.stat_id    = e.stat_id
        AND e.stat_name IN ('DB time','DB CPU' ,'background elapsed time','background cpu time')
      )
      pivot (SUM(value) FOR stat_name IN ('DB time' tdbtim ,'DB CPU' tdbcpu ,'background elapsed time' tbgtim ,'background cpu time'  tbgcpu)))
  )
  ,
  sql_dbt AS
  (
    SELECT
      --h.sql_id,
      h.force_matching_signature,
      ROUND(h.time_per_exec*100/d.tdbtim,2) pctdbtim
    FROM
      (
        SELECT
          --sql_id,
          force_matching_signature,
          SUM(time_per_exec*execs) time_per_exec
        FROM
          per_time
        GROUP BY
          --sql_id
          force_matching_signature
      )
      h,
      db_time d
  )
  ,
  avg_time AS
  (
    SELECT
      dbid,
      --sql_id,
      force_matching_signature,
      MEDIAN(time_per_exec) med_time_per_exec,
      STDDEV(time_per_exec) std_time_per_exec,
      AVG(time_per_exec) avg_time_per_exec,
      MIN(time_per_exec) min_time_per_exec,
      MAX(time_per_exec) max_time_per_exec
    FROM
      per_time
    GROUP BY
      dbid,
      --sql_id
      force_matching_signature
    HAVING
      COUNT(*) >= &&captured_at_least_x_times.
      --AND MAX(days_ago) - MIN(days_ago) >=
      -- &&captured_at_least_x_days_apart.
    AND MEDIAN(time_per_exec) >  &&med_elap_microsecs_threshold.
  )
  ,
  time_over_median AS
  (
    SELECT
      h.dbid,
      --h.sql_id,
      h.force_matching_signature,
      h.days_ago,
      (h.time_per_exec / a.med_time_per_exec) time_per_exec_over_med,
      a.med_time_per_exec,
      a.std_time_per_exec,
      a.avg_time_per_exec,
      a.min_time_per_exec,
      a.max_time_per_exec
    FROM
      per_time h,
      avg_time a
      --WHERE a.sql_id = h.sql_id
    WHERE
      a.force_matching_signature = h.force_matching_signature
  )
  ,
  ranked AS
  (
    SELECT
      RANK () OVER (ORDER BY ABS(REGR_SLOPE(t.time_per_exec_over_med,
      t.days_ago)) DESC) rank_num,
      t.dbid,
      --t.sql_id,
      t.force_matching_signature,
      CASE
        WHEN REGR_SLOPE(t.time_per_exec_over_med, t.days_ago) > 0
        THEN 'IMPROVING'
        ELSE 'REGRESSING'
      END change,
      ROUND(REGR_SLOPE(t.time_per_exec_over_med, t.days_ago), 3)
      slope,
      ROUND(AVG(t.med_time_per_exec)/1e6, 3) med_secs_per_exec,
      ROUND(AVG(t.std_time_per_exec)/1e6, 3) std_secs_per_exec,
      ROUND(AVG(t.avg_time_per_exec)/1e6, 3) avg_secs_per_exec,
      ROUND(MIN(t.min_time_per_exec)/1e6, 3) min_secs_per_exec,
      ROUND(MAX(t.max_time_per_exec)/1e6, 3) max_secs_per_exec
    FROM
      time_over_median t
    GROUP BY
      t.dbid,
      --t.sql_id
      t.force_matching_signature
    HAVING
      ABS(REGR_SLOPE(t.time_per_exec_over_med, t.days_ago)) >  &&min_slope_threshold.
  )
SELECT
  row_n,
  --r.sql_id,
  r.force_matching_signature,
  change,
  slope,
  s.pctdbtim,
  lpad(med_secs_per_exec,15,' ') med_secs_per_exec,
  lpad(std_secs_per_exec,15,' ') std_secs_per_exec,
  lpad(avg_secs_per_exec,15,' ') avg_secs_per_exec,
  lpad(min_secs_per_exec,15,' ') min_secs_per_exec,
  lpad(max_secs_per_exec,15,' ') max_secs_per_exec
  -- plans,
  --sql_text_80
FROM
  (
    SELECT
      LPAD(ROWNUM, 2) row_n,
      --r.sql_id,
      r.force_matching_signature,
      r.change,
      --TO_CHAR(r.slope, '990.000MI') slope,
      ROUND(r.slope,2) slope,
      --TO_CHAR(s.pctdbtim,'99.9999') ela_pct_dbtime,
      TO_CHAR(r.med_secs_per_exec, '999,990.000') med_secs_per_exec,
      TO_CHAR(r.std_secs_per_exec, '999,990.000') std_secs_per_exec,
      TO_CHAR(r.avg_secs_per_exec, '999,990.000') avg_secs_per_exec,
      TO_CHAR(r.min_secs_per_exec, '999,990.000') min_secs_per_exec,
      TO_CHAR(r.max_secs_per_exec, '999,990.000') max_secs_per_exec
      --(SELECT COUNT(DISTINCT p.plan_hash_value) FROM
      -- dba_hist_sql_plan p WHERE p.dbid = r.dbid AND p.sql_id =
      -- r.sql_id) plans,
      --REPLACE((SELECT sys.DBMS_LOB.SUBSTR(s.sql_text, 80) FROM
      -- dba_hist_sqltext s WHERE s.dbid = r.dbid AND s.sql_id =
      -- r.sql_id), CHR(10)) sql_text_80
    FROM
      ranked r
    WHERE
      r.rank_num <= &&max_num_rows.
    ORDER BY
      r.rank_num
  )
  r,
  sql_dbt s
WHERE
  r.force_matching_signature = s.force_matching_signature
ORDER BY
  row_n
/

                                                   Total Elapsed     Median Secs    Std Dev Secs        Avg Secs        Min Secs     Max Secs
#             FORCE_MATCHING CHANGE           SLOPE     % DB Time        Per Exec        Per Exec        Per Exec        Per Exec     Per Exec
-- ------------------------- ------------- -------- ------------- --------------- --------------- --------------- --------------- ---------------
 1      15936051349132279638 REGRESSING        -.62           .15         151.788         140.202         222.579         131.888      384.062

SQL>

min_elapsed_time


define min_elapsed_time=10
define min_repeat_executions_filter=10

col 1 FOR 99999 
col 2 FOR 99999 
col 3 FOR 9999 
col 4 FOR 999 
col 5 FOR 99 
col av FOR 99999 
col ct FOR 99999 
col mn FOR 999 
col av FOR 99999.9 
col MAX_RUN_TIME FOR a40 
col longest_sql_exec_id FOR A20
set linesize 500
set pages 9999

WITH pivot_data AS
  (SELECT sql_id,
    ct,
    mxdelta mx,
    mndelta mn,
    ROUND(avdelta) av,
    WIDTH_BUCKET(delta_in_seconds,mndelta,mxdelta+.1,5) AS bucket ,
    SUBSTR(times,12) max_run_time,
    SUBSTR(longest_sql_exec_id, 12) longest_sql_exec_id
  FROM
    (SELECT sql_id,
      delta_in_seconds,
      COUNT(*) OVER (PARTITION BY sql_id) ct,
      MAX(delta_in_seconds) OVER (PARTITION BY sql_id) mxdelta,
      MIN(delta_in_seconds) OVER (PARTITION BY sql_id) mndelta,
      AVG(delta_in_seconds) OVER (PARTITION BY sql_id) avdelta,
      MAX(times) OVER (PARTITION BY sql_id) times,
      MAX(longest_sql_exec_id) OVER (PARTITION BY sql_id) longest_sql_exec_id
    FROM
      (SELECT sql_id,
        sql_exec_id,
        MAX(delta_in_seconds) delta_in_seconds ,
        LPAD(ROUND(MAX(delta_in_seconds),0),10)
        || ' '
        || TO_CHAR(MIN(start_time),'YY-MM-DD HH24:MI:SS')
        || ' '
        || TO_CHAR(MAX(end_time),'YY-MM-DD HH24:MI:SS') times,
        LPAD(ROUND(MAX(delta_in_seconds),0),10)
        || ' '
        || TO_CHAR(MAX(sql_exec_id)) longest_sql_exec_id
      FROM
        ( SELECT sql_id, TO_CHAR(sql_exec_id)||'_'||to_char(sql_exec_start,'J') sql_exec_id,
        CAST(sample_time AS    DATE) end_time,
        CAST(sql_exec_start AS DATE) start_time,
        ((CAST(sample_time AS DATE)) - (CAST(sql_exec_start AS DATE))) * (3600*24) delta_in_seconds
      FROM dba_hist_active_sess_history
      WHERE sql_exec_id IS NOT NULL
      AND sql_id='00nxwgnnnhd9z'
      )
    GROUP BY sql_id,
      sql_exec_id
    )
  )
WHERE ct >
  &min_repeat_executions_filter
AND mxdelta >
  &min_elapsed_time )
SELECT                        *
FROM pivot_data PIVOT ( COUNT(*) FOR bucket IN (1,2,3,4,5))
ORDER BY mx DESC,
  av DESC ;
  
   5
------------- ------ ---------- ---- -------- ---------------------------------------- -------------------- ------ ------ ----- ---- ---
00nxwgnnnhd9z     43       1123  411    995.0 24-07-30 16:32:52 24-07-30 16:51:35      16777217_2460522          2      1     0    3  37

SQL>

from https://blog.go-faster.co.uk/2019/10/purging-sql-statements-and-execution.html

 
set lines 300 pages 99
col costpctdiff         heading 'Cost|%Diff' format 99999 
col costdiff            heading 'Cost|Diff' format 99999999 
col plan_hash_value     heading 'SQL Plan|Hash Value'
col child_number        heading 'Child|No.' format 9999
col inst_id             heading 'Inst|ID' format 999
col hcost                heading 'AWR|Cost' format 99999999999
col ccost             heading 'Cursor|Cost' format 9999999
col htimestamp         heading 'AWR|Timestamp'
col ctimestamp         heading 'Cursor|Timestamp'
col end_interval_time format a26
col snap_id         heading 'Snap|ID' format 99999999
col awr_cost format 9999999999999
col optimizer_Cost heading 'Opt.|Cost' format 99999999
col optimizer_env_hash_value heading 'Opt. Env.|Hash Value'
col num_stats heading 'Num|Stats' format 9999
alter session set nls_date_format = 'hh24:mi:ss dd.mm.yy';
break on plan_hash_value skip 1 on sql_id on dbid
ttitle 'compare AWR/recent plan costs'

with h as ( /*captured plan outside retention limit*/
select  p.dbid, p.sql_id, p.plan_hash_Value, max(cost) cost
,       max(p.timestamp) timestamp
from    dba_hist_sql_plan p 
,       dba_hist_wr_control c
where   p.dbid = c.dbid
and     p.cost>0
and     (p.object_owner != 'SYS' OR p.object_owner IS NULL)  --omit SYS owned objects
and     p.timestamp < sysdate-c.retention 
group by p.dbid, p.sql_id, p.plan_hash_value
), s as ( /*SQL statistics*/
select  t.dbid, t.sql_id, t.plan_hash_value, t.optimizer_env_hash_value
,       t.optimizer_cost
,       MIN(t.snap_id) snap_id
,       MIN(s.end_interval_time) end_interval_time
,       COUNT(*) num_stats
from    dba_hist_snapshot s
,       dba_hist_sqlstat t
where   s.dbid = t.dbid
and     s.snap_id = t.snap_id
and     t.optimizer_cost > 0
GROUP BY t.dbid, t.sql_id, t.plan_hash_value, t.optimizer_env_hash_value
,       t.optimizer_cost
), x as (
Select  NVL(h.dbid,s.dbid) dbid
,       NVL(h.sql_id,s.sql_id) sql_id
,       NVL(h.plan_hash_value,s.plan_hash_value) plan_hash_value
,       h.cost hcost, h.timestamp htimestamp
,       s.snap_id, s.end_interval_time
,       s.optimizer_env_hash_value, s.optimizer_cost
,       s.num_stats
,       s.optimizer_cost-h.cost costdiff
,       100*s.optimizer_cost/NULLIF(h.cost,0) costpctdiff
From    h join s
on      h.plan_hash_value = s.plan_hash_value
and     h.sql_id = s.sql_id
and     h.dbid = s.dbid
), y as (
SELECT  x.*
,       MAX(ABS(costpctdiff)) OVER (PARTITION BY dbid, sql_id, plan_hash_value) maxcostpctdiff
,       MAX(ABS(costdiff)) OVER (PARTITION BY dbid, sql_id, plan_hash_value) maxcostabsdiff
FROM    x
)
SELECT  dbid, sql_id, plan_hash_value, hcost, htimestamp
,       snap_id, end_interval_time, optimizer_env_hash_value, optimizer_cost, num_stats, costdiff, costpctdiff
FROM    y
WHERE   maxcostpctdiff>=10
And     maxcostabsdiff>=10
order by plan_hash_value,sql_id,end_interval_time
/
break on report
ttitle off


set linesize 500 pagesize 400

VARIABLE BgnSnap NUMBER
VARIABLE EndSnap NUMBER

exec select max(snap_id) -100 into :BgnSnap from dba_hist_snapshot ;
exec select max(snap_id) into :EndSnap from dba_hist_snapshot ;

col SQL_TEXT for a50

WITH
per_phv AS (
SELECT 
       h.dbid,
       h.sql_id,
       h.plan_hash_value,
       MIN(s.begin_interval_time) min_time,
       MAX(s.end_interval_time) max_time,
       MEDIAN(h.elapsed_time_total / h.executions_total) med_time_per_exec,
       STDDEV(h.elapsed_time_total / h.executions_total) std_time_per_exec,
       AVG(h.elapsed_time_total / h.executions_total)    avg_time_per_exec,
       MIN(h.elapsed_time_total / h.executions_total)    min_time_per_exec,
       MAX(h.elapsed_time_total / h.executions_total)    max_time_per_exec,
       STDDEV(h.elapsed_time_total / h.executions_total) / AVG(h.elapsed_time_total / h.executions_total) std_dev,
       MAX(h.executions_total) executions_total,
       MEDIAN(h.elapsed_time_total / h.executions_total) * MAX(h.executions_total) total_elapsed_time
  FROM dba_hist_sqlstat h,
       dba_hist_snapshot s
 WHERE h.snap_id BETWEEN :BgnSnap AND :EndSnap
  -- AND h.dbid = dbid
   AND h.executions_total > 1
   AND h.plan_hash_value > 0
   AND s.snap_id = h.snap_id
   AND s.dbid = h.dbid
   AND s.instance_number = h.instance_number
   AND CAST(s.end_interval_time AS DATE) > SYSDATE - 7
   and PARSING_SCHEMA_NAME='ANUJ'
 GROUP BY
       h.dbid,
       h.sql_id,
       h.plan_hash_value
),
ranked1 AS (
SELECT 
       RANK () OVER (ORDER BY STDDEV(med_time_per_exec)/AVG(med_time_per_exec) DESC) rank_num1,
       dbid,
       sql_id,
       COUNT(*) plans,
       SUM(total_elapsed_time) total_elapsed_time,
       MIN(med_time_per_exec) min_med_time_per_exec,
       MAX(med_time_per_exec) max_med_time_per_exec
  FROM per_phv
 GROUP BY
       dbid,
       sql_id
HAVING COUNT(*) > 1
),
ranked2 AS (
SELECT 
       RANK () OVER (ORDER BY r.total_elapsed_time DESC) rank_num2,
       r.rank_num1,
       r.sql_id,
       r.plans,
       p.plan_hash_value,
       TO_CHAR(CAST(p.min_time AS DATE), 'YYYY-MM-DD/HH24') min_time,
       TO_CHAR(CAST(p.max_time AS DATE), 'YYYY-MM-DD/HH24') max_time,
       ROUND(p.med_time_per_exec / 1e6, 3) med_secs_per_exec,
       p.executions_total executions,
       ROUND(p.med_time_per_exec * p.executions_total / 1e6, 3) aprox_tot_secs,
       ROUND(p.std_time_per_exec / 1e6, 3) std_secs_per_exec,
       ROUND(p.avg_time_per_exec / 1e6, 3) avg_secs_per_exec,
       ROUND(p.min_time_per_exec / 1e6, 3) min_secs_per_exec,
       ROUND(p.max_time_per_exec / 1e6, 3) max_secs_per_exec
      --, REPLACE(DBMS_LOB.SUBSTR(s.sql_text, 1000), CHR(10)) sql_text
  FROM ranked1 r,
       per_phv p,
       dba_hist_sqltext s
 WHERE r.rank_num1 <= 20 * 5
   AND p.dbid = r.dbid
   AND p.sql_id = r.sql_id
   AND s.dbid(+) = r.dbid AND s.sql_id(+) = r.sql_id
)
SELECT 
       r.sql_id,
       r.plans,
       r.plan_hash_value,
       r.min_time,
       r.max_time,
       r.med_secs_per_exec,
       r.executions,
       r.aprox_tot_secs,
       r.std_secs_per_exec,
       r.avg_secs_per_exec,
       r.min_secs_per_exec,
       r.max_secs_per_exec
    --   ,r.sql_text
  FROM ranked2 r
 WHERE rank_num2 <= 20
 ORDER BY
       r.rank_num2,
       r.sql_id,
       r.min_time,
       r.plan_hash_value;


set linesize 300 

define sql_id='xxxxxxx' ;

WITH
p AS (
SELECT plan_hash_value
  FROM gv$sql_plan
WHERE 1=1 
and sql_id = TRIM('&sql_id')
   AND other_xml IS NOT NULL
UNION
SELECT plan_hash_value
  FROM dba_hist_sql_plan
WHERE 1=1 
and sql_id = TRIM('&sql_id')
   AND other_xml IS NOT NULL ),
m AS (
SELECT plan_hash_value,
       SUM(elapsed_time)/SUM(executions) avg_et_secs
  FROM gv$sql
WHERE 1=1 
and sql_id = TRIM('&sql_id')
   AND executions > 0
GROUP BY
       plan_hash_value ),
a AS (
SELECT plan_hash_value,
       SUM(elapsed_time_total)/SUM(executions_total) avg_et_secs
  FROM dba_hist_sqlstat
WHERE 1=1 
and sql_id = TRIM('&sql_id')
   AND executions_total > 0
GROUP BY
       plan_hash_value )
SELECT distinct p.plan_hash_value,
       ROUND(NVL(m.avg_et_secs, a.avg_et_secs)/1e6, 3) avg_et_secs, d.SQL_ID, trunc(d.TIMESTAMP) as DATE_CREATED
  FROM p, m, a, dba_hist_sql_plan d
WHERE p.plan_hash_value = m.plan_hash_value(+)
   AND p.plan_hash_value = a.plan_hash_value(+)
   AND p.plan_hash_value = d.plan_hash_value
ORDER BY
       SQL_ID asc, DATE_CREATED NULLS LAST;
	   
	   



Oracle DBA

anuj blog Archive