ADOP PHASES

 Prepare Phase:


  • Prepares the system for patching cycle.
  • Creates the Database Patch Edition
  • Validates system configuration
  • Check & Submit Concurrent Request 'Online Patching In Progress'(ADZDPATCH)
  • Prepare is run on all nodes in a mute-node configuration
  • Synchronizes the Run and Patch File System
  • If cleanup was not executed in previous adop cycle it will also run Cleanup.


Syntax:
adop phase=prepare

Apply Phase:

  • Patches are applied in this phase.
  • Adop internally calls adpatch to apply the patches, but we cannot run adpatch utility as standalone in R12.2 .
  • Patches are applied in the Patch Edition.
  • Application user are connected to RUN edition and they are not impacted by patching cycle.
  • We can apply multiple patches in a patching cycle.



Syntax:
adop phase=apply

Finalize Phase:

  • Ready the system for Cutover.
  • Compile Invalid objects.
  • If we don't run finalize, then the cutover phase will call finalize automatically before doing the actual cutover. But that will increase the downtime window for the cutover.
  • Computes any DDL to be executed before the cutover.


Synatx:
adop phase=finalize

Cutover Phase:

  • Switches to the patch edition of database and file system.
  • In the phase, the system actually goes down.
  • All application tier services are stopped and starts after the cutover.


Syntax:
adop phase=cutover

Cleanup Phase:


  • Cleans up old edition and objects.
  • Recovers space.


Syntax:
adop phase=cleanup



Adop opttions:

https://docs.oracle.com/cd/E26401_01/doc.122/e22954/T202991T531062.htm

{ echo systempasswd; echo appspasswd ; echo weblogicpaswd ; }|adop phase=apply  patches=31883479_D:u31883479.drv,31883479_ESA:u31883479.drv,31883479_HR:u31883479.drv,31883479_PL:u31883479.drv,31883479_RU:u31883479.drv,31883479_SK:u31883479.drv apply_mode=downtime merge=yes prompt=no 

GATHER SCHEMA STATS

 Why sometimes gather stats runs for longer time than normal.

There are many possible causes but the most common are:

a)  Database/application process or processes are running which are updating the database. When GSS runs it will invalidate all of the stats on the object it is analyzing. If a process then trying to update or use that table it will start doing full table scan which will affect the overall database performance, which in turn impact GSS.

b)  Large amount of data has been added to the database. The more records you have the longer the GSS will take to complete the process.

c)  Recollecting CBO stats on tables that have not changed. If a table has 100 million rows then gathering stats on that table will take a long time, however if no or little changes are made then there is no need to delete all of the old stats and regather them (which is what you are doing)

d)  Gathering statistics invalidates cursors which can hamper performance.( Unless you use the ‘No Invalidate’ option)

 

IMPORTANT TABLES/VIEWS RELATED TO GATHER SCHEMA STATISTICS

1)      FND_STATS_HIST

To record the time taken for gathering the statistics for the different types of objects.

2)      FND_HISTOGRAM_COLS

Gather Schema stats create the histogram for the specified columns in the tables.

 

IMPORTANT SCRIPTS RELATED TO GATHER SCHEMA STATISTICS

1) If the custom schema is not registered, it will not show up in the LOV for schema selection for the mentioned concurrent programs.

You can run the following statement to see which schemas are currently registered with the Ebusiness Suite:

select distinct(upper(oracle_username)) sname

from fnd_oracle_userid a, fnd_product_installations b
where a.oracle_id = b.oracle_id order by sname;

 

How to verify if the current gathered statistics are correct?

 We use the Verify Stats report to determine whether the current statistics are accurate.

This report is a utility provided with FND_STATS, and can be run as follows:

SQL> set server output on

SQL> set long 10000

SQL> exec fnd_stats.verify_stats(‘schema’, ‘object_name’);

 

GATHER SCHEMA STATISTICS NOT RUNNING FOR CUSTOM MODULES. WHY?

When we submit Gather Schema Stats with Parameter  ALL, concurrent request will complete successfully but  custom schemas may not get analyzed.

Script to check if custom schema is analyzed :

Sql > select count(table_name)  from  dba_tables  where  last_analyzed  is  not null  and  owner= <custom_schema_name>;

Gather Schema Statistics program gathers statistics for all schemas , however it skips custom schemas registered in Oracle Applications.

Reason:

Whenever Custom schemas are registerd in Oracle Applications , the entries are done in 2 tables

ie  FND_ORACLE_USERID  and  FND_APPLICATIONS_TL

However , when Gather schema statistics is submitted it uses the below query to get schema information

Sql > select distinct upper(oracle_username) sname

from fnd_oracle_userid a,

fnd_product_installations b

where a.oracle_id = b.oracle_id

order by sname;

Note : When custom schemas are created the entry is not made in  FND_PRODUCT_INSTALLATIONS  and hence it is not picked up in the above query.

Solution :

Go to the Responsibility called Alert Manager and Navigate to the form -> Installations under Systems Menu.

Define custom application in this form. Go to the last record and make entry for custom applications. Once this is done , it will insert an entry in fnd_product_installations.

Submit Gather Schema stats and then query dba_tables and you will realize , stats are being gathered for custom schemas as well.



http://expertoracle.com/2013/02/01/gather-statistics-in-r12-and-11i/



 why we run datapatch:

The datapatch utility will run the necessary apply scripts to load the modified SQL files into the database. Entires will be added to both DBA_REGISTRY_HISTORY and DBA_REGISTRY_SQLPATCH views automatically.

DEBAM1> SELECT patch_id, status FROM dba_registry_sqlpatch;


  PATCH_ID STATUS

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

  22139226 SUCCESS

  21948354 SUCCESS

  20204035 SUCCESS

  22139226 SUCCESS

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

  30805558 END

  20204035 END

  31219939 END

  31113348 BEGIN



it will update like begin then end then sucess





Why we use open resetlogs?

Qn 1 :

A RESETLOGS is required in either of


a. Recovery using BACKUP CONTROLFILE

b. Incomplete Recovery


If you are using a Backup controlfile (whether from a Binary Backup or actually via a CREATE CONTROLFILE), the Controlfile is not current -- therefore it does not have the database SCN and LogSequenceNumbers. The RESETLOGS updates this information back to the controlfile (normally, a Recovery is the other way round with the controlfile's SCN, being the highest, driving the Recovery).

Also, a Resetlogs is required in both cases to ensure that the older Redo Logs (e.g. they might still be on disk) are not used -- the Resetlogs creates a new Incarnation of the database.


Qn 2:

There is no difference between an ALTER DATABASE OPEN; and an ALTER DATABASE OPEN NORESETLOGS;.

The NORESETLOGS is the default action in an OPEN if you do not specify RESETLOGS.


(Obviously, Oracle check to see if you have used a Backup Controlfile and/or done an Incomplete Recovery, in which case it does not allow you to OPEN without the RESETLOGS).




AUTOCONFIG IS NOT RUN FOR ALL PATCHES

  ###############WHY AUTOCONFIG IS NOT RUN DURING PATCH########

 Skipping ...

 Running AutoConfig since none of its templates were

 patched during this run of adpatch.

BLOCK CORRUPTION and BMR

 BLOCK CORRUPTION:

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

DB maintaince may occur unfortunately and one of the case we can say block corruption.

whenever we find that we are unable to view the data as excepted. We can observer it is block corruption.

Block corruption may happen below scenario's:

1.Hard disk

2.Powerfailuers

3.N/W Issues.

4.OS Issues

 

Identify methods for block corruption:

1.DBA_BLOCKCORRUPTION

2.DBVERIFY='datafile location'(OS COMMANDS).

3.USING RMAN(Validate datafile, tablespace)


Block media recover :

To do Block Media Recover the database should be in mount or open state.

Connect to RMAN target database.

then fire Recover 

CHECKPOINT AND BEGIN BACKUP MODE USES

 CHECKPOINT

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

Checkpoint is mandatory background process which is requested by DBWR when its being writing data from buffer to data files.

It is used for synchronize the buffer and datafiles

Checkpoint only updates header information to data files whenever DBWR completes writing to datafiles.

Checkpoint update Highest SCN number to all Datafiles from buffer. 

Checkpoint occurs from bellow scenario's:

1.DB normal shutdown

2.DBA manual triggered checkpoint.(alter system checkpoint)

3.When its reaches three seconds or PGA_TARGET parameter value.

4.if we defined fast_mttr value then if it reaches fast_mttr.

5.Alter database begin backup mode;

6.when datafile goes offline.


Reorg tables&indexes in EBS and Normal DB

Case:

Usually in OLTP environment like EBS Applications, tables are often get fragmented due to multiple DML activities that happens.Fragmented tables cause queries on those tables to slow down. It is very important to de-fragment this table and to reclaim the fragmented space from these objects.

For EBS we have also seen  that usually gathered statistics, indexing and proper SQL tuning is plenty to improve and maintain acceptable performance but sometime it is required to reorg the table.

One primary cause of fragmentation is that when you run delete command on the tables it delete the rows but doesn’t frees up the memory and also do not changes the high water mark.

We have also seen that this requirement for doing reorg is more required in Demantra applications and since Demantra is both OLTP and data warehouse the applications we  must tune accordingly so that query run time can be optimum.

Although this article focus on the EBS/Demantra application tables but it is true for all oracle databases.

WHAT CAUSES FRAGMENTATION

As DML activity happens in the database, it is possible for there to be discontinuous chunks, or fragments of unused space within the tablespace and fragmentation within the table rows.

When you insert  or update row in table

As rows are added to tables, the table expands into unused space within the space. It will naturally fragment as discontiguous data blocks are fetched to receive new rows. Updating table records may also cause row chaining if the updated row can’t fit into same data block.

When you delete rows from table

At deletion, a table may coalesce extents, releasing unused space back into the tablespace. A lot of deletes leaves high-water mark behind at a high value. It will cause slower full-table-scan performance since Oracle must read to the high water mark.

WHY FRAGMENTATION IS BAD FOR DATABASE

Fragmentation can make a database run inefficiently.

a) Negative Performance impact – SQL  statements that performs full-scan and large index range scans may run more slowly in a fragmented table. When rows are not stored contiguously, or if rows are split onto more than one block, performance decreases because these rows require additional block accesses.

b) Wasted Disk Space – It means you have space in your disk which your database can not use.

 

REORG PROCESS

The main goal of table reorganization is to reduce IO when accessing the big database tables.

1. Reorders the table data according to the primary key index.
2. Column reordering to push columns that have no data, nulls, to the end of the table row

The column reordering can be very useful for tables that have 300+ columns many of the columns are null. When the null columns are pushed to the end of the row, the read operation becomes streamlined thus increasing performance.

We usually follow below process for counter table fragmentation. We have also mentioned some good scripts related to data fragmentation at that end of this article.

 

STEP 1) GATHER STATISTICS

First you need to check exact difference in table actual size (dba_segments) and stats size (dba_tables). The difference between these value will report actual fragmentation to us. This means we need to have updated stats in the dba_tables for the tables.

To understand how we collect latest statistics in EBS, please see this earlier article Gather Statistics in R12 (and 11i)

 

STEP 2) CHECK FOR FRAGMENTATION

Execute Script 1 provided below to find the fragmented tables

It is important that you execute step 1 for gathering statistics first before you run this script or else result will be inaccurate.

This script will show you tables which are more fragmented. You can identify tables which are frequently used in your problematic long running queries and target those for reorg process.

Please note that it is not always a good idea to reorganize a partitioned table. Partitioning of data is considered an efficient data organization mechanism which boosts query performance.

 

STEP 3) REORG THE IDENTIFIED FRAGMENTED TABLES

We have multiple options to reorganize fragmented tables:

 METHOD 1. Alter table move (to another tablespace, or same tablespace) and rebuild indexes:-

 METHOD 2. Export and import the table

 METHOD 3. Shrink command . (applicable for tables which are tablespace with auto segment space management)

 

Method 1 is most popular and is described below:

 

METHOD 1. Alter table move

 

A) Check Table size and Fragmentation in table

It is good idea to check and record what is the current size and fragmentation in table using script 1 provided below

 

B) Collect indexes details

Execute below command to find the indexes details

select index_name,status from dba_indexes where table_name like '&table_name';

 

C) Move table in to same or new tablespace

For moving into same tablespace execute below:

alter table <table_name> move;

For moving into another tablespace, first find Current size of you table from dba_segments and check if any other tablespace has free space available

alter table <table_name> enable row movement;

alter table <table_name> move tablespace <new_tablespace_name>;

After that move back the table to original tablespace

alter table table_name move tablespace old_tablespace_name;

 

D) Rebuild all indexes

We need to rebuild all the indexes as move command will make all the index unusable. Run the alter index command one by one for each index.

select status,index_name from dba_indexes where table_name = '&table_name';

alter index <INDEX_NAME> rebuild online; 

select status,index_name from dba_indexes where table_name = '&table_name';

 

E) Gather table stats

For EBS application’s datbase we use FND_STATS package

exec fnd_stats.gather_table_stats('&owner_name','&table_name');

For normal oracle database, we use DBMS_STATS

exec dbms_stats.gather_table_stats('&owner_name','&table_name');

 

F) Check Table size and Fragmentation in table

Now again check table size using script 1.

In our case we were able to reduce the table size from 4 GB to 0.15 GB as the table was highly fragmented.

 It is also good idea to see if there are any new invalid objects in database and run utlrp.sql to compile objects.

 

IMPORTANT SCRIPTS

Some good scripts related to re-org:

Script 1: To locate highly fragmented tables

select

 table_name,round(((blocks*8)/1024/1024),2) "size (gb)" ,

 round(((num_rows*avg_row_len/1024))/1024/1024,2) "actual_data (gb)",

 round((((blocks*8)) - ((num_rows*avg_row_len/1024)))/1024/1024,2) "wasted_space (gb)",

 round(((((blocks*8)-(num_rows*avg_row_len/1024))/(blocks*8))*100 -10),2) "reclaimable space %",

 partitioned

from

 dba_tables

where

 (round((blocks*8),2) > round((num_rows*avg_row_len/1024),2))

order by 4 desc;

 

Script 2: To find how are data blocks used for a specific table

set serveroutput on

 

declare

 v_unformatted_blocks number;

 v_unformatted_bytes number;

 v_fs1_blocks number;

 v_fs1_bytes number;

 v_fs2_blocks number;

 v_fs2_bytes number;

 v_fs3_blocks number;

 v_fs3_bytes number;

 v_fs4_blocks number;

 v_fs4_bytes number;

 v_full_blocks number;

 v_full_bytes number;

 begin

 dbms_space.space_usage (

 'APPLSYS',

 'FND_CONCURRENT_REQUESTS',

 'TABLE',

 v_unformatted_blocks,

 v_unformatted_bytes,

 v_fs1_blocks,

 v_fs1_bytes,

 v_fs2_blocks,

 v_fs2_bytes,

 v_fs3_blocks,

 v_fs3_bytes,

 v_fs4_blocks,

 v_fs4_bytes,

 v_full_blocks,

 v_full_bytes);

 dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);

 dbms_output.put_line('Blocks with 00-25% free space = '||v_fs1_blocks);

 dbms_output.put_line('Blocks with 26-50% free space = '||v_fs2_blocks);

 dbms_output.put_line('Blocks with 51-75% free space = '||v_fs3_blocks);

 dbms_output.put_line('Blocks with 76-100% free space = '||v_fs4_blocks);

 dbms_output.put_line('Full Blocks = '||v_full_blocks);

 

end;

 /

 

This will give output like below:

Unformatted Blocks = 64

 Blocks with 00-25% free space = 0

 Blocks with 26-50% free space = 516

 Blocks with 51-75% free space = 282

 Blocks with 76-100% free space = 282

 Full Blocks = 10993

 PL/SQL procedure successfully completed.

 

Note

How to Deallocate Unused Space from a Table, Index or Cluster. (Doc ID 115586.1)
How to Determine Real Space used by a Table (Below the High Water Mark) (Doc ID 77635.1)
Reclaiming Unused Space in an E-Business Suite Instance Tablespace (Doc ID 303709.1)
How to Re-Organize a Table Online (Doc ID 177407.1)
Reorg Failiure : Demantra Reorg Failing On SALES_DATA (Doc ID 2209718.1)Demantra Table Reorganization, Fragmentation, Null Columns, Primary Key, Editioning, Cluster Factor, PCT Fee, Freelist, Initrans, Automatic Segment Management (ASM), Blocksize…. (Doc ID 1990353.1)
SEGMENT SHRINK and Details. (Doc ID 242090.1)