Apr 7, 2016

Table Rebuilds To Improve Performance - Reorg Tables

In OLTP database environment some times performance degraded because of Table plan changes, row-chaining and Row-migration issues. Based on transactions on table, it may require maintenance activities such as table reorganization. After table reorg, it is seen performance improved a lot.

How to determine whether a table "reorg" is needed or not?

1. It is recommended to test in similar prod/pre-prod environment with gather statistics on the required table.  The preferred percentage for the gather is 100%.

2. Run the following SQL to evaluate how table reorg might affect Primary Key (PK) based access:

Run using sys user:

SELECT di.index_name,
       trunc((dt.num_rows / di.clustering_factor) /
             (dt.num_rows / dt.blocks),2)
  FROM dba_indexes di, dba_tables dt, dba_constraints dc
 WHERE di.table_name = dt.table_name
   AND dt.table_name = dc.table_name
   AND di.index_name = dc.index_name
   AND dc.CONSTRAINT_TYPE = 'P'
   AND dt.table_name = upper('&Table_Name');


3. As per the result for above query:

VALUE ABOVE 0.75 - DOES NOT REQUIRE REORG

VALUE BETWEEN 0.5 AND 0.75 - REORG IS RECOMMENDED

VALUE LOWER THAN 0.5 - IT IS HIGHLY RECOMMENDED TO REORG


Note:  Before change in production, must be tested dev/ preprod env. Load test must be followed.

To gather table stats with 100% sampling:

exec dbms_stats.gather_table_stats('&owner','&Table_Name',estimate_percent => 100, cascade=>true, method_opt=>'for all columns size AUTO');

Oracle 10g and 11g : "FOR ALL COLUMNS SIZE AUTO" - This setting means that DBMS_STATS decides which columns to add histogram to where it believes that they may help to produce a better plan.


Gathering statistics for all objects in a schema:

exec dbms_stats.gather_schema_stats(ownname => '&Schema_name ',cascade => TRUE,method_opt => 'FOR ALL COLUMNS SIZE AUTO' );


Ref:
Oracle support Doc ID : 1587179.1

Apr 2, 2016

To find segment name from Corrupt Block

Find segment name from Corrupt Block:

Message from Alert Log :


Fri Apr 01 13:56:27 2016
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_pr04_4915260.trc:
ORA-00339: archived log does not contain any redo
ORA-00334: archived log: '/u02/flash_recovery_area/PROD/PROD/onlinelog/o1_mf_1_chsdf09j_.log'
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_pr04_4915260.trc (incident=4243):
ORA-00600: internal error code, arguments: [kdBlkCheckError], [80], [1288987], [6264], [], [], [], [], [], [], [], []
Incident details in: /u01/app/oracle/diag/rdbms/PROD/PROD/incident/incdir_4243/PROD_pr04_4915260_i4243.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Slave exiting with ORA-10562 exception
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_pr04_4915260.trc:
ORA-10562: Error occurred while applying redo to data block (file# 80, block# 1288987)
ORA-10564: tablespace REGISTRATION
ORA-01110: data file 80: '/u02/flash_recovery_area/PROD/ORADATA/hr01.dbf'
ORA-10561: block type 'TRANSACTION MANAGED DATA BLOCK', data object# 89532
ORA-00600: internal error code, arguments: [kdBlkCheckError], [80], [1288987], [6264], [], [], [], [], [], [], [], []
............................


In the alert log we found that datafile 80 has corrupt block and the dartafile is hr01.dbf. The corrupted block is "1288987".

Then run below query to find segment name :

1) Query-1: Find segment name with owner

SQL> select * from dba_extents where file_id = 80 and 1288987 between block_id and block_id + blocks -1 ; 


2) Query-2: Find object details

SQL> select * from dba_objects where object_name='MLOG$_PATIENT' and object_type='TABLE'; 


It will help you.


Apr 1, 2016

Fix : ORA-10562: Error occurred while applying redo to data block

During recovering in standby using manual process ( no DG configured), I found below error in laert log.

Error in Alert Log:

Thu Mar 31 10:42:10 2016
Dumping diagnostic data in directory=[cdmp_20160331104210], requested by (instance=1, osid=23658610 (PR01)), summary=[incident=4
226].
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Slave exiting with ORA-10562 exception
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_pr01_23658610.trc:
ORA-10562: Error occurred while applying redo to data block (file# 80, block# 1288553)
ORA-10564: tablespace sample
ORA-01110: data file 80: '/u02/flash_recovery_area/PROD/ORADATA/sample01.dbf'
ORA-10561: block type 'TRANSACTION MANAGED DATA BLOCK', data object# 89532
ORA-00600: internal error code, arguments: [kdBlkCheckError], [80], [1288553], [6264], [], [], [], [], [], [], [], []
Recovery Slave PR01 previously exited with exception 10562
Thu Mar 31 10:42:10 2016
Errors with log /u03/restore_archive/2016_03_30/thread_2_seq_625.1575.907832317
MRP0: Background Media Recovery terminated with error 448
Errors in file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_pr00_9109508.trc:
ORA-00448: normal completion of background process
Recovery interrupted!

Solution:

(1) Take backup of related datafiles.(in primary)

e.g.,
RMAN> backup datafile 80 format '/u02/df_80_pr.bk' ;

Now transfer this backup piece to standby server.

(2) In standby : catalog the backup piece location 

RMAN > catalog backuppiece '/u03/backup_files/df_80_pr.bk';

Then list it for confirmation.

RMAN> list backuppiece'/u03/backup_files/df_80_pr.bk';
RMAN> list backup of datafile 80; # Check the backup piece

(3) Cancel MRP if started.

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

(4) Restore from backup piece:

e.g., restore datafile 80; # restore datafile 80 ;

RMAN> restore datafile 80;

Starting restore at 31-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=199 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00080 to /u02/flash_recovery_area/PROD/ORADATA/sample01.dbf
channel ORA_DISK_1: reading from backup piece /u03/backup_files/df_80_pr.bk
channel ORA_DISK_1: piece handle=/u03/backup_files/df_80_pr.bk tag=TAG20160331T121840
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 31-MAR-16

RMAN>

(5) Start the MRP in standby:

SQL> alter database recover managed standby database disconnect ;

Sure, It will apply archivelogs again.

Thanks .


Fix : DBV-00008: USERID must be specified for OSM files

One of my friend get below error while running dbv command for a datafile which was available in ASM disk group.

Err:   DBV-00008: USERID must be specified for OSM files

Here is sample error:

$ dbv file='+DATA/PROD/datafile/sample01.dbf'

DBVERIFY: Release 11.2.0.4.0 - Production on Fri Apr 1 14:02:30 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.


DBV-00008: USERID must be specified for OSM files


So, you give the username and password via userid, then it will work fine.

Sample Example :

$ dbv userid=registration/reg40 file=+DATA/PROD/datafile/sample01.dbf 

DBVERIFY: Release 11.2.0.4.0 - Production on Fri Apr 1 14:05:27 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = +DATA/PROD/datafile/sample01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 1365512
Total Pages Processed (Data) : 836672
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 84780
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 360647
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 83413
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 0 (0.0)



Thanks .

Translate >>