Disclaimer

Thursday, 2 September 2021

RMAN

 RECOVERY  MANAGER (RMAN)

 

How do u know how much RMAN task has been completed?

By querying v$rman_status or v$session_longops



 

What is snapshot control file?

The snapshot CONTROLFILE is a copy of the CONTROLFILE that RMAN utilizes during long running operation (such as backup). 


RMAN needs a read consistent view of the CONTROLFILE for the backup operation, but by its nature the control file is extremely volatile. 


Instead of putting lock on the control file and causing all kinds of db enqueue problems, RMAN makes a copy of controlfile called snapshot controlfile. 


The snapshot is refreshed at the beginning of every backup.


 

What is the difference between auxiliary channel and maintenance channel ?


AUXILIARY:

Specifies a connection between RMAN and an auxiliary database instance.

An auxiliary instance is used when executing the DUPLICATE or TRANSPORT TABLESPACE command, and when performing TSPITR with RECOVER TABLESPACE 


When specifying this option, the auxiliary instance must be started but not mounted


 

Command to delete archive logs older than 7days?


RMAN> delete archivelog all completed before sysdate-7;



 

What is the difference between backup set and backup piece?


Backup set is logical and backup piece is physical.



 

RMAN command to backup for creating standby database?


RMAN> duplicate target database to standby database ....

 




How to do cloning by using RMAN?


RMAN> duplicate target database …

 


How to put manual/user-managed backup in RMAN (recovery catalog)?


By using catalog command.

RMAN> CATALOG START WITH '/tmp/backup.ctl';


 

Retaining Backups for a Long Time


Use the keep option with the backup command to retain backups beyond what’s mandated by the retention polices that you’ve configured.


run

{

backup database tag quarterly keep until time 'sysdate+180'

restore point 2007Q1;

}


You can use the keep forever option during a backup command to exempt a backup copy from any retention policies:


run

{

backup database tag quarterly keep forever

restore point Y2007Q1;

}

 


Restarting Backups After a Backup Crash

Use the restartable backup feature to back up only those files that failed to be backed up the first time around. Use the not backed up since time clause of the backup command to restart a backup after it partially completes


RMAN> backup not backed up since time 'sysdate-1' database plus archivelog;

 

Updating Image Copies


By using incrementally updated image copies, you can avoid making time-consuming full image copy backups of datafiles. 

To use the incrementally updated backups feature, you first make a full image copy backup of a datafile and, at regular intervals, update the initial image

copy of the datafile with level 1 incremental backups of that datafile. You use the backup ... for recover of copy form of the backup command to incrementally

update an image copy, as shown here:


run 

{

recover copy of database with tag 'incr_update';

backup incremental level 1 for recover of copy with tag 'incr_update'

database;

}


By running the previous script daily, you’ll never have to apply more than a day’s worth of redo to recover the database, thus dramatically reducing the time needed to perform a media recovery of the database.

 



Using LogMiner to Find an SCN

A user accidentally dropped a table. You want to find the SCN associated with that drop statement so that you can restore the database to the SCN just prior to the accidental drop. 

You can use LogMiner to find SCNs associated with DML and DDL statements. LogMiner requires supplemental logging to be enabled to be able to display information about DML statements. Enable supplemental logging by issuing the following SQL:


Recovering a Subset of Datafiles  You want to perform incomplete recovery on a subset of datafiles in your database. The basic procedure is to determine which datafiles you don’t want to restore and recover and

then use alter database datafile ... offline for drop for the datafiles to be excluded.

 





Skipping Tablespaces During Database Duplication


You want to skip certain tablespaces when duplicating a database

run

{

allocate channel C1 device type disk;

allocate auxiliary channel C2 device type disk;

duplicate database to aux skip tablespace users, tools;

}


As soon as RMAN opens the new auxiliary database, it’ll start dropping all tablespaces that are part of the skip tablespace command. The tablespace drop is done using the option including contents cascade constraints. RMAN drops the tablespaces in a reverse sorted list of tablespace names. You’ll get errors if you try to exclude tablespaces that contain indexes used for enforcing unique or primary keys.

 



Resynchronizing a Duplicate Database


You want to synchronize a duplicate database with its parent database Once you create a duplicate database from a source database, you can periodically “update”

or synchronize the duplicate database by simply rerunning the duplicate command over again, in essence re-creating the duplicate database


RMAN> connect auxiliary sys/sammyy1@dupdb

RMAN> duplicate target database to dupdb

logfile

group 1 ('/duplogs/redo01a.log',

'/duplogs/redo01b.log') size 200k reuse,

group 2 ('/duplogs/redo02a.log',

'/duplogs/redo02b.log') size 200k reuse;


You can schedule this script for running on a daily or a weekly basis, thus creating a new and up-to-date duplicate database on a continuous basis.

 



Image copies:


An image copy is a copy of a single file (datafile, archivelog, or controlfile)

  It is very similar to an O/S copy of the file

  It is not a backupset or a backup piece

  No compression is performed

 


Snapshot Controlfile:


When RMAN needs to resynchronize from a read-consistent version of the control file, it creates a temporary snapshot control file   The default name for the snapshot control file is port-specific

 


Can I restore or duplicate my RMAN backup between two different platforms such as Solaris to Linux?

In general, you cannot restore or duplicate between two different platforms.

 



Connection hanging? what are the possibilities?

Possibilities for Oracle hanging include:


External issues - The network being down, Kerberos security issues, SSO or a firewall issue can cause an Oracle connection to hang.

One way to test this is to set sqlnet.authentication_services=(none) in your sqlnet.ora file and retry connecting.


Listener is not running - Start by checking the listener (check lsnrctl stat). Also, see my notes on diagnosing Oracle network connectivity issues.


No RAM - Over allocation of server resources, usually RAM, whereby there is not enough RAM to spawn another connection to Oracle.


Contention - It is not uncommon for an end-user session to “hang” when they are trying to grab a shared data resource that is held by another end-user.

The end-user often calls the help desk trying to understand why they cannot complete their transaction, and the Oracle professional must quickly identify the source of the contention."

 




How to make RMAN backup or restore faster?

To make it faster, it can be configured to use PARALLELISM with multiple channels:

 




How to identify all the corrupted segments in the database reported by RMAN?


Step 1: Identify the corrupt blocks (Datafile Block Corruption - Intra block corruption)

RMAN> backup validate check logical database;

To make it faster, it can be configured to use PARALLELISM with multiple channels:

RMAN> run {

allocate channel d1 type disk;

allocate channel d2 type disk;

allocate channel d3 type disk;

allocate channel d4 type disk;

backup validate check logical database;

}


Step2:  Using the view v$database_block_corruption:

SQL> select * from v$database_block_corruption;

 

          FILE#          BLOCK#          BLOCKS CORRUPTION_CHANGE# CORRUPTIO

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

              6              10                          1          8183236781662                      LOGICAL

              6              42                          1                  0                                      FRACTURED

              6              34                          2                  0                                      CHECKSUM

              6              50                          1      8183236781952                          LOGICAL

              6              26                          4                  0                                      FRACTURED

 


Datafile Block Corruption - Intra block corruption

It refers to intra block corruptions that may cause different errors like ORA-1578, ORA-8103, ORA-1410, ORA-600 etc.

Oracle classifies the corruptions as Physical and Logical

To identify both Physical and Logical Block Corruptions use the "CHECK LOGICAL" option,  It checks the complete database for both corruptions without actually doing a backup

 

Solution1:

RMAN> backup check logical validate database;

RMAN> backup check logical database;



Solution2:

 Chek the view V$DATABASE_BLOCK_CORRUPTION to identify the block corruptions detected by RMAN

Solution3: DBVerify - Identify Datafile Block Corruptions

->DBVERIFY identify Physical and Logical Intra Block Corruptions by default

->Dbverify cannot be run for the whole database in a single command

->It does not need a database connection either

dbv  file=   blocksize=

 

RMAN Vs DBVerify - Datafile Intra Block Corruption

->When the logical option is used by RMAN, it does exactly the same checks as DBV does for intra block corruption.

->RMAN can be run with PARALLELISM using multiple channels making it faster than DBV which can not be run in parallel in a single command.

->DBV checks for empty blocks. In 10g RMAN may not check blocks in free extents when Locally Managed Tablespaces are used. In 11g RMAN checks for both free and used extents.

->Both DBV and RMAN (11g) can check for a range of blocks. RMAN: VALIDATE DATAFILE 1 BLOCK 10 to 100;. 

DBV: start=10 end=100

->RMAN keeps corruption information in the control file (v$database_block_corruption, v$backup_corruption). DBV does not.

->RMAN may not report the corruption details like what is exactly corrupted in a block reported as a LOGICAL corrupted block. DBV reports the corruption details in the screen or in a log file.

->DBV can scan blocks with a higher SCN than a given SCN.

->DBV does not need a connection to the database.

 



Integrating RMAN with a Media Manager on UNIX:

On UNIX, Oracle accesses the media management library through the UNIX shared library libobk.so. This file must exist somewhere in the system path. It is highly recommended that you place libobk.so in $ORACLE_HOME/lib, which is where Oracle searches first.

You do not need to start or shut down the instance when installing the media management library.



To integrate the media manager on UNIX:

If an old libobk.so symbolic link already exists in $ORACLE_HOME/lib, then remove it before installing the media manager.

$ rm $ORACLE_HOME/lib/libobk.so After installation, check your media management vendor documentation to determine where the media management library is installed. For example, suppose that the library is installed as /vendor/lib/oracle_lib.so.

Either changes the name of the installed media management library to $ORACLE_HOME/lib/libobk.so, or created a symbolic link to the library called libobk.so. For example, you can create a symbolic link to the library as follows:

$ ln -s /vendor/lib/oracle_lib.so $ORACLE_HOME/lib/libobk.so

Alternatively, you can simply change the name of the library to libobk.so

 $mv /vendor/lib/oracle_lib.so $ORACLE_HOME/lib/libobk.so





 

DATA GUARD

 DATA GUARD

 

What are different types of modes in Data Guard and which is default?

Maximum performance:

This is the default protection mode.

It provides the highest level of data protection that is possible without affecting the performance of a primary database.

This is accomplished by allowing transactions to commit as soon as all redo data generated by those transactions has been written to the online log.

Maximum protection:

This protection mode ensures that no data loss will occur if the primary database fails.

To provide this level of protection, the redo data needed to recover a transaction must be written to both the online redo log and to at least one standby database before the transaction commits.

To ensure that data loss cannot occur, the primary database will shut down, rather than continue processing transactions.

Maximum availability:

This protection mode provides the highest level of data protection that is possible without compromising the availability of a primary database.

Transactions do not commit until all redo data needed to recover those transactions has been written to the online redo log and to at least one standby database.

 

What is the pre-requisite for creating standby DB?

Primary DB must be in force logging mode.

What is the pre-requisite for switchover to standby DB?

No session connected to standby or primary DB.

select switchover_status from v$database;

‘To Primary’ or ‘To Standby’ and not ‘Session Active’

 

Insufficient disk space or UNNAMED or MISSING in the standby database

There are many reasons for a file being created as UNNAMED or MISSING in the standby database, including insufficient disk space on standby site (or) Improper parameter settings related to file management.

alter database create datafile '/oracle/app/oracle/product/10.2.0/db_1/dbs/UNNAMED00536' as new;

 

How many standby databases we can create (in 10g/11g)?

Till Oracle 10g, 9 standby databases are supported.

From Oracle 11g R2, we can create 30 standby databases.

 

What are the parameters we’ve to set in primary/standby for Data Guard ?

DB_UNIQUE_NAME

LOG_ARCHIVE_CONFIG

LOG_ARCHIVE_MAX_PROCESSES

DB_CREATE_FILE_DEST

DB_FILE_NAME_CONVERT

LOG_FILE_NAME_CONVERT

LOG_ARCHIVE_DEST_n

LOGARCHIVE_DEST_STATE_n

FAL_SERVER

FAL_CLIENT

STANDBY_FILE_MANAGEMENT

 

What is the use of fal_server & fal_client, is it mandatory to set these ?

FAL_SERVER

Specifies the FAL (fetch archive log) server for a standby database. The value is an Oracle Net service name, which is assumed to be configured properly on the standby database system to point to the desired FAL server.

FAL_CLIENT

Specifies the FAL (fetch archive log) client name that is used by the FAL service, configured through the

FAL_SERVER initialization parameter, to refer to the FAL client. The value is an Oracle Net service name, which is assumed to be configured properly on the FAL server system to point to the FAL client (standby database).

 

What are differences between physical, logical, snapshot standby and ADG (or) what are different types of standby databases?

 

Physical standby – in mount state, MRP will apply archives

ADG – in READ ONLY state, MRP will apply archives

Logical standby – in READ/WRITE state, LSP will run

Snapshot standby databases – Physical standby database can be converted to snapshot standby database, which will be in READ WRITE mode, can do any kind of testing, then we can convert back snapshot standby database to physical standby database and start MRP which will apply all pending archives.

 

How to find out backlog of standby?

select round((sysdate - a.NEXT_TIME)*24*60) as "Backlog",m.SEQUENCE#-1 "Seq Applied",m.process, m.status

from v$archived_log a, (select process,SEQUENCE#, status from v$managed_standby where process like '%MRP%')m where a.SEQUENCE#=(m.SEQUENCE#-1);

 

If you didn't have access to the standby database and you wanted to find out what error has occurred in a data guard configuration, what view would you check in the primary database to check the error message?

You can check the v$dataguard_status view.

select message from v$dataguard_status;

 

How can u recover standby which far behind from primary (or) without archive logs how can we make standby sync?

By using RMAN incremental backup.

 

What is snapshot standby (or) How can we give a physical standby to user in READ WRITE mode and let him do updates and revert back to standby?

Till Oralce 10g, create guaranteed restore point, open in read write, let him do updates, flashback to restore point, start MRP.

From Oracle 11g, convert physical standby to snapshot standby, let him do updates, convert to physical standby, start MRP.

 

What are new features in 11g Data Guard?

Here is some data guard category and there enhancement

1) Data Protection

Advanced Compression

Lost-write protection

Fast-Start Failover

2) Increase ROI

Active Data Guard

Snapshot Standby

3) High Availability

Faster Redo Apply

Faster failover & switchover

Automatic Failover using ASYNC

4) Manageability

Mixed Windows/Linux

 

What are the uses of standby redo log files?

A standby redo log is required for the maximum protection and maximum availability modes and the LGWR ASYNC transport mode is recommended for all databases. Data Guard can recover and apply more redo data from a standby redo log than from archived redo log files alone.

If the real-time apply feature is enabled, log apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived.

This results in faster switchover and failover times because the standby redo log files have been applied already to the standby database by the time the failover or switchover begins.

 

What is dg_config ?

Specify the DG_CONFIG attribute to identify the DB_UNIQUE_NAME for the primary database and each standby database in the Data Guard configuration.

The default value of this parameter enables the primary database to send redo data to remote destinations and enables standby databases to receive redo data.

 

 What is RTA (real time apply) mode MRP?

Real-time apply where before log shipping the LGWR process writes to a standbylog file simultaneously along with the online redolog file.

This standby logfile is written to standby log file on standby server. There is no loss of any committed transaction whatsoever in Real-Time Apply scenario.

In Real Time Apply, once a transaction is committed on the Primary, the committed changes will be available on the Standby in Real Time even without switching the log at the Primary

MRP - Managed recovery process - For Data Guard, the background process that applies archived redo log to the standby database.

 

What is StaticConnectIdentifier property used for?

11gr2 new database property, StaticConnectIdentifier, which allows the user to specify a static connect identifier that the DGMGRL client will use to start database instances.

 

What is the difference between normal MRP (managed apply) and RTA MRP (real time apply)?

The difference between Redo Apply & Real-Time Apply

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

Normally, by default, Archiver processes will be responsible for Redo Transport from Primary to Standby.

Once a log switch happens on the Primary, the online redo log is archived in the Local Archive destination as pointed to by Log_archive_dest_1

by an Archiver process.

Another Archiver process will then transmit the redo to the remote standby destination as indicated by Log_archive_dest_2.

Data Guard Remote File Server (RFS) Process on the Standby then writes redo data from the Standby redo log file to archive redo log file.

Log apply services then makes use of Managed Recovery Process (MRP) process to apply the redo to the standby database.

This method of propagating redo from the primary to standby is called Redo Apply and it happens only on log switch at the Primary.

When using Redo Apply mode, the status of MRP in v$managed_standby view will show as WAIT_FOR_LOG.

Real Time Apply, in contrast, uses either LGWR or Archiver on the Primary to write redo data to Standby Redo log on the Standby and Log Apply Services can apply the redo data in real-time without the need of the current standby redo log being archived. Once a transaction is committed on the Primary, the committed changes will be available on the Standby in Real Time even without switching the log.

When using Real Time Apply mode, the status of MRP in v$managed_standby view will show as APPLYING_LOG.

 

What are the background processes involved in Data Guard?

MRP, LSP, 

What is failover/switchover (or) what is the difference between failover & switchover?

Switchover – This is done when both primary and standby databases are available. It is pre-planned.

Failover – This is done when the primary database is NO longer available (ie in a Disaster). It is not pre-planned.

Why extra standby redo log group?

Determine the appropriate number of standby redo log file groups.Minimally, the configuration should have one more standby redo log file group than the number of online redo log file groups on the primary database....

(maximum number of logfiles for each thread + 1) * maximum number of threads

Using this equation reduces the likelihood that the primary instance's log writer (LGWR) process will be blocked because a standby redo log file cannot be allocated on the standby database. For example, if the primary database has 2 log files for each thread and 2 threads, then 6 standby redo log file groups are needed on the standby database."

I think it says that if you have groups #1 and #2 on primary and #1, #2 on standby, and if LGWR on primary just finished #1, switched to #2, and now it needs to switch to #1 again because #2 just became full, the standby must catch up, otherwise the primary LGWR cannot reuse #1 because the standby is still archiving the standby's #1. Now, if you have the extra #3 on standby, the standby in this case can start to use #3 while its #1 is being archived. That way, the primary can reuse the primary's #1 without delay.

 

Why Primary DB stop shipping archive log or redo to standby server?

->Check sys password change on the primary db, verify the password file timestamp on primary and standby server.

->DG Broker might have changed the init parameter.

->Check listener or TNS entry.

->Check Network

 

Snapshot Standby

in Oracle Database 11g, where the physical standby database can be temporarily converted into an up dateable one called Snapshot Standby Database. In that mode, you can run your app—which may modify a lot of tables—and gauge its impact. Once the impact is assessed, you can convert the database into a standby undergoing the normal recovery. This is accomplished by creating a restore point in the database, using the Flashback database feature to flashback to that point and undo all the changes

First, start recovery on the standby, if not going on already:

 

SQL> alter database recover managed standby database disconnect;

SQL> alter database recover managed standby database cancel;

At this point, you may create the snapshot standby database. Remember, it enables Flashback logging, so if you haven't configured the flash recovery area, you will get a message like this:

ORA-38784: Cannot create restore point 'SNAPSHOT_STANDBY_REQUIRED_01/12/2008

00:23:14'.

ORA-38786: Flash recovery area is not enabled.

To avoid that, you should have already created flash recovery area. If you didn't, don't worry, you can create it now:

SQL> alter system set db_recovery_file_dest_size = 2G;

SQL> alter system set db_recovery_file_dest= '/db_recov';

Now that the formalities are completed, you can convert this standby database to snapshot standby using this simple command:

SQL> alter database convert to snapshot standby;

Now recycle the database:

SQL> shutdown immediate

SQL> startup

Now the database is open for read/write operations:

SQL> select open_mode, database_role  from v$database;

OPEN_MODE  DATABASE_ROLE

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

READ WRITE SNAPSHOT STANDBY

 

You can do changes in this database now. This is a perfect place to replay the captured workload using Database Replay. You can then perform the system changes in this database and replay several times to see the impact of the changes. As this is a copy of the production database, the replay will be an accurate representation of the workload.

 

After your testing is completed, you would want to convert the snapshot standby database back to a regular physical standby database. Just follow the steps shown below:

     

SQL> shutdown immediate

SQL> alter database convert to physical standby;

 Now shutdown, mount the database and start managed recovery.

SQL> shutdown

SQL> startup mount

Start the managed recovery process:

SQL> alter database recover managed standby database disconnect;

 

Now the standby database is back in managed recovery mode. Needless to say, when the database was in snapshot standby mode, the archived logs from primary were not applied to it. They will be applied now and it may take some time before it completely catches up.

 

Active Data Guard

With Oracle Database 11g, that situation changes: You can open the physical standby database in read-only mode and restart the recovery process. This means you can continue to be in sync with primary but can use the standby for reporting

->Stop Managed Recovery process on standby.

->Open standby database as read-only.

->Restart managed recover process on the standby db.

alter database recover managed standby database using logfile disconnect;

Now the standby db is updated but it is simultaneously open for read-only.

 

How can we clone database with rman backup?

DUPLICATE DATABASE TO DB11G  FROM ACTIVE DATABASE   SPFILE  NOFILENAMECHECK;

 

Setting Archive Tracing for Data Guard

alter system set log_archive_trace=15

By default the log_archive_trace parameter is set to zero, meaning archive log tracing is disabled.

Level 8192: Tracks redo apply activity (media recovery or physical standby)

 

 

Data Guard Broker

alter system set dg_broker_start=TRUE/FALSE

alter system set  dg_broker_config_file1='file_name1’

alter system set  dg_broker_config_file2='file_name2’

Create Configuration

DGMGRL>CREATE CONFIGURATION 'DG_BBIDEV' AS PRIMARY DATABASE IS 'BBIDEV' CONNECT IDENTIFIER IS 'BBIDEV';

Verify configuration

DGMGRL> show configuration;

Verify database;

DGMGRL> show database 'BBIDEV';

Add standby database to the configuration

DGMGRL> ADD DATABASE 'BBIDEV_SB' AS CONNECT IDENTIFIER IS BBIDEV_SB MAINTAINED AS PHYSICAL;

Enable or Disable the broker

DGMGRL> ENABLE/DISABLE CONFIGURATION;

Verify Configuration

DGMGRL>show database 'BBIDEV' StatusReport;

DGMGRL>show database 'BBIDEV' LogxpStatus;

DGMGRL>show database 'BBIDEV' InconsistentProperties;

DGMGRL>Edit database  'BBIDEV' SET PROPERTY 'LogXpMode'='SYNC';

Performing a Switchover Operation

DGMGRL>Switchover to 'STDBY_BBIDEV';

Remove the broker configuration

DGMGRL> REMOVE CONFIGURATION;

 

AUTOMATIC WORKLOAD REPOSITORY

 AUTOMATIC WORKLOAD REPOSITORY

 

What are the different AWR reports can be generated?

awrrpt.sql -> Normal AWR report on standalone DB.

awrGrpt.sql -> RAC AWR report for entire RAC node.

AwrDDrpt.sql -> AWR difference period report

awrSQrpt.sql ->AWR specific SQL_ID report for analysis

awrGDrpt-> AWR Global Diff report

 

Do the quick analysis of AWR report

 

->In the AWR Header Report, check Elapsed Time (time between two snapshots) and DB Time (Total activity on the DB), if DB TIME is greater than Elapsed Time then it means database has high workload.

->Load Profile: It provides an at-a-glance look at some specific operational statistics. You can compare these statistics with a baseline snapshot to determine if DB activity is different.

->Instance Efficiency %:  Buffer Nowait, Buffer Hit, Library Hit, Redo No Wait, In-memory Sort, Soft Parse, Latch Hit, Non-Parse CPU.

The above ratios should be above 90% in a DB.

Check hard parsing , not using bind variables.

->Top 5 Timed Foreground Events:

This section provides insight into what events the Oracle DB is spending most of its time on. In Top 5 Timed Event, use the Highest Wait Times to guide the investigation.

Wait Events are:

DB File Scattered Read: That generally happens a Full Table Scan or Fast Full Index Scans. As FTS’s are pulled into memory ,they are rarely fall into contiguous buffers but instead are scattered throughout the buffer cache. A large number here indicates that your table may have missing indexes, statistics are not updated or your indexes are not used. You can use the report to help identify the query in question and fix it.

DB File Sequential Read: This is the wait times come from physical side of the DB. It is related to memory starvation and non-selective index. Sequential read is an index read followed by table read because it is doing index lookups which tells exactly which block to go to. This could indicate poor joining order of tables or un-selective indexes in your SQL or waiting for writes to TEMP space. Need to tune PGA_AGGREGATE_TARGET. When DB File Sequential Read and DB File Scattered Read occurred in conjunction in the Top 5 Wait Events section first you should examine the SQL Ordered Physical Reads section of the report.

CPU TIME: This is the sum of the CPU used by the session. If the CPU time event is the biggest event , find the SQL statements that access the most blocks (Buffer gets and Logical I/O). The report lists such SQL statements in section SQL ordered by Gets.

Latch Free: Latches are low-level mechanism used to protect shared memory structures in the SGA. Latches are like locks on the memory that are quickly obtained and released. Latches are used to prevent concurrent access to a shared memory structure. If the latch is not available, latch free miss is recorded. Most latch problems are related to the failure to use bind variables (Library Cache Latch), redo generation issue (Redo Allocation Latch), buffer cache contention issue( Cache Buffer LRU Chain) and hot blocks in the buffer cache (Cache Buffer Chain). When Latch Miss Ration is >0.5% you should investigate the issue.

Enqueue: It is a lock that protects a shared resources. Lock protect shared resources, such  as data in record, to prevent two people updating the same data at the same time application.

->Time Model Statistics: If the SQL Time > DB CPU Time then probably have IO issue.

->SQL Information Section:

Any SQL statements appears in the TOP 5 statements in two or mode areas below , then it is prime candidate for tuning.

SQL Ordered By Elapsed Time: IO waits

SQL Ordered by CPU Time: Sorting/ Hashing

SQL Ordered by Buffer Gets: High Logical IO

SQL Ordered by Disk Reads: High physical IO

SQL Order by Executions: May indicate Loop issues

SQL Order by Parse Calls: Memory issues.

SQL Ordered by Version Count: May indicates unsafe bind variables

->I/O Stats Section: From this report you can determine if the TBS or Datafiles are suffering from sub-standard performance in term of IO response from the disk sub-system.

->Advisory Statistics Section

In this section we receive several recommendations on changing the size of different buffer pools from Advisories such as Buffer Pool Advisory, PGA Memory Advisory, Shared Pool Advisory and SGA Target Advisory  that we can perform and how that will affect the overall performance on the DB.

->Segments Statistics Sections:

This is a series of reports that let you identify objects that are heavily used such as segment by logical read and segment by physical read. These reports can help you find objects that are HOT objects in the database.

 

What you’ll check whenever user complains that his session/database is slow?

If the user is giving SID and query is still running, first of all we will check the sql_id, event ,last_call_et, seq# from v$session.

We will monitor the event and last_call_et to identify what’s query actually doing and what is the elasped_time  also we will check seq# is changing or not. If the seq# is not changing that means, there is a contention. After that I will investigate further to identify that which session is blocking. Blocking and waiting session can be identified by looking into v$session, v$process and v$lock

DBA_WAITERS View that retrieve information for each session waiting on a lock

DBA_BLOCKERS View that gives the blocking sessions  

To find out how long a session has been blocked by another session.

select sid, username, event, blocking_session,

seconds_in_wait, wait_time

from v$session where state in ('WAITING');

Check the database for blocking locks as well as latch contention.

select sid,serial#,status,event,seq#,username,machine,sql_id from v$session where sid in (588);

select sql_fulltext from v$sql where sql_id='4yv506w29vx57';

 

->Check the CPU , Memory Utilization, Paging and Swapping using top,prstat,topas, free ,vmstat to ensure the problem was not from Hardware Resource.

->Check the alert log file for any ORA error at a glance if it is hitting any bug or logical corruption.

->Check the no. of INACTIVE SESSIONs on the database for a long time holding resource using V$SESSION.LAST_CALL_ET.

->Check the blocking and waiting sessions on the database using V$SESSION,V$PROCESS and V$LOCK.

->Identify and retrieve the query if the SID is given by the user using V$SESSION and V$SQL.

->Find the TABLES in the query and identify the indexes on the tables.If the views are present in the query then extract the view metadata using DBA_VIEWS.TEXT and check the TABLES in the view.

->Check the OPTIMIZER STATISTICS are updated on both TABLES AND its INDEXES using DBA_TABLES.LAST_ANALYZED and DBA_INDEXES.LAST_ANALYZED    and check the STATUS of INDEXES it should not be UNUSABLE.

->Check the TABLES and INDEXES FRAGMENTATION using no. of rows in the table and avg_row_len of the TABLES and check the size of TABLES and INDEXES using DBA_SEGMENTS.BYTES and estimate the FRAGMENTATION %.

->Generate the Execution Plan for problematic SQL query using SET AUTOTRACE TRACEONLY EXPLAIN and enable the timing using SET TIMING ON command.

->Read the indented explain plan line by line and identify the highest COST and CPU % utilization and highest no. of rows retrieves and its size.

->Check the Access Method (FTS and Index Scan)

->Check the Joins on column (Sort Merge Join (SMJ),Nested Loops (NL),Hash Join, Cartesian Product)

->Check the indexes on the join column, if the function is using in the join or there is concatenated joins , ensure that there is function based index and composite indexes available on the joins. Also check the column name and column position using DBA_IND_COLUMNS view to ensure that the indexes are on the right column.

->Break up the SQL query into smaller part to confirm which query is causing performance degradation.

->Use the Hint or Optimizer Parameter to influence the OPTIMIZER to change the plan to get better execution plan.

->Ensure that query is not using SQL PROFILE if it is using try to disable SQL PROFILE for the query so OPTIMIZER use different execution plan.

 

Check system stats AUX_STATS$


FTS or Full Table Scan

Whole table is read upto high water mark

Uses multiblock I/O

Buffer from FTS operation is stored in LRU end of buffer cache


Index Unique Scan

Single block I/O


Index Fast Full Scan

Multi block I/O possible

Returned rows may not be in sorted order


Index Full Scan:

Single blockI/O

Returned rows generally will be in sorted order

 

 

Undo Queries

  SQL> SQL> select sum(bytes /(1024*1024*1024)) from dba_undo_extents where status='EXPIRED'; select sum(bytes /(1024*1024*102...