Friday, October 10, 2025

Read-Only Oracle Home in 23ai

 About Read-Only Oracle Homes 


            Alireza Kamrani 

              


Read-Only Oracle Homes (ROOH) were introduced in Oracle Database 18c and have become the recommended default structure for newer Oracle installations. The idea is to separate static, immutable binaries from instance-specific and writable files — making database software more secure, easier to manage, and simpler to patch or clone.


In 23ai:

With Oracle Database 23ai, an Oracle home is available in read/write mode by default. However, you can choose to configure an Oracle home in read-only mode after you have performed a software-only Oracle Database installation.

A read-only Oracle home does not imply that the file system and the Oracle home is in read-only mode. The file system and mount point should always be in read/write mode.

A read-only Oracle Home simplifies provisioning by implementing separation of installation and configuration.

In a read-only Oracle home, the configuration data and log files reside outside of the read-only Oracle home. 


Apart from the traditional ORACLE_BASE andORACLE_HOME directories, the following directories contain files that used to be in ORACLE_HOME:

Ensure that you enable read-only Oracle home before you create the database or listener.

When you run the roohctl script to enable a read-only Oracle home, the Oracle home file system will continue to be a read/write file system.


Note:

This feature does not affect how database administrators monitor, diagnose, and tune their system performance.


Key Benefits:

1. Simplified Patching

•Patch once → apply everywhere.

Since the binaries are immutable, you can:

•Maintain one gold (reference) home image.

•Deploy or patch by replacing the home instead of in-place patching.

•This makes rolling patching, cloning, and rollback operations much faster and safer.


2. Improved Security

•The home being read-only means:

•No accidental or malicious changes to Oracle binaries.

•Reduces attack surface since configuration and logs are stored elsewhere.

•Protects integrity of Oracle software from OS-level tampering.


3. Simplified Administration

•No need to separate writable and read-only files manually.

•Easier configuration management — all instance-specific writable files (e.g., listener config, tnsnames, sqlnet.ora) are automatically redirected to the appropriate directory under $ORACLE_BASE_HOME.

•Supports multiple databases or instances sharing a single home safely.


4. Faster Deployment and Cloning

•You can clone a read-only home simply by copying it to another server — no need to reconfigure.

•When you deploy, only instance-specific config is customized in $ORACLE_BASE_HOME.

•Great for cloud or fleet-managed environments.


5. Reduced Storage and Maintenance Overhead

•Shared read-only binaries across databases minimize duplication.

•Less storage needed for multiple homes.

•Easier to keep environments consistent (no “drift” between installations).


6. Better Compliance and Auditing

•Software binaries are immutable — simplifying validation for compliance (e.g., SOX, ISO, PCI).

•Changes to configuration are centralized and easier to track.


About Oracle Base Config

Both, in a read-only ORACLE_HOME and read/write ORACLE_HOME, the configuration files reside in a location known as ORACLE_BASE_CONFIG.


In a read/write ORACLE_HOME, the ORACLE_BASE_CONFIG path is the same as the ORACLE_HOME path because it is located at $ORACLE_HOME. However, in a read-only ORACLE_HOME, the ORACLE_BASE_CONFIG path is the same as ORACLE_BASE.


ORACLE_BASE_CONFIG/dbs contains the configuration files for ORACLE_HOME. Each file in the dbs directory contains $ORACLE_SID so that the directory can be shared by many different ORACLE_SIDs.


To print the ORACLE_BASE_CONFIG path, run the orabaseconfig command from the $ORACLE_HOME/bin directory:


$ setenv ORACLE_HOME /u01/app/oracle/product/23.0.0/dbhome_1

$ cd $ORACLE_HOME/bin

$ ./orabaseconfig


The orabaseconfig command returns the location of ORACLE_BASE_CONFIG irrespective of whether the home is a read-only ORACLE_HOME or a read/write ORACLE_HOME. 


For example, to know the location of configuration files like SPFILE and the password file, run orabaseconfig:


Example: Output in Read-Only ORACLE_HOME


$ ./orabaseconfig

/u01/app/oracle


Where, /u01/app/oracle is the ORACLE_BASE.

Example 12-4 Output in Read/Write ORACLE_HOME


$ ./orabaseconfig

/u01/app/oracle/product/23.0.0/dbhome_1


where, /u01/app/oracle/product/23.0.0/dbhome_1is the ORACLE_HOME.


Enabling a Read-Only Oracle Home

Configure your Oracle home as a read-only Oracle home after you have performed a software-only Oracle Database installation.

To enable a read-only Oracle home:

  1. Perform a software-only Oracle Database installation.
  2. Run the roohctl -enable script.
  3. Run Oracle Database Configuration Assistant (Oracle DBCA) to create a database.


Note:

Ensure that you enable read-only Oracle home before you create the database or listener.


Software-Only Database Installation

  1. Log in as the Oracle installation owner user account (oracle) that you want to own the software binaries.
  2. Download the Oracle Database installation image files (db_home.zip) to a directory of your choice. For example, you can download the image files to the /tmp directory.
  3. Create the Oracle home directory and extract the image files that you have downloaded in to this Oracle home directory. For example:

    $ mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1
  4. $ chown oracle:oinstall /u01/app/oracle/product/19.0.0/dbhome_1
  5. $ cd /u01/app/oracle/product/19.0.0/dbhome_1
  6. $ unzip -q /tmp/db_home.zip


    Note
    Ensure that the Oracle home directory path you create is in compliance with the Oracle Optimal Flexible Architecture recommendations. Also, unzip the installation image files only in this Oracle home directory that you created.
  7. From the Oracle home directory, run the runInstaller command to start the Oracle Database installer. 
  8. In the Select Configuration Option screen, select Set Up Software Only.
  9. Select your installation type. Installation screens vary depending on the installation option you select. Respond to the configuration prompts as needed.


Run the roohctl Script

  1. Go to the bin directory

    $ cd /u01/app/oracle/product/19.0.0/dbhome_1/bin
  2. Run the roohctl script to enable read-only Oracle home.

    $ ./roohctl -enable 
  3. On Oracle Real Application Clusters (Oracle RAC) installations, run the preceding roohctl script on every node of the cluster. Alternatively, run the roohctl script with the nodelistoption and provide the list of cluster nodes:

    $ ./roohctl –enable –nodelist 
    comma_separated_list_of_nodes

Copying demo Directories to Oracle Base Home

In a read-only mode ORACLE_HOME, you must copy the demo directories listed in this topic from ORACLE_HOME to ORACLE_BASE_HOME.

Oracle Database contains various demo directories that include a variety of examples and product demonstrations that you can use to learn about the products, options, and features of Oracle Database. In a read-only mode ORACLE_HOME, you cannot use these demo directories in ORACLE_HOME because writes are performed to these demodirectories when they are used.


Many of the demo directories are not available by default. You must install Oracle Database Examples to view and use the examples and product demonstrations.

Copy the respective demo directory to the corresponding location in ORACLE_BASE_HOME. Now, you can use this copy of the demo directory.


You must copy the following demo directories from ORACLE_HOME to ORACLE_BASE_HOME:

You must also create symbolic links for the odbc/demo, precomp/demo, rdbms/demo, and xdk/demo demo directories. See the "Creating Symbolic Links" section in this topic.


Copying demo Directories

For example, to copy the rdbms/demo directory from ORACLE_HOME to ORACLE_BASE_HOME, perform the following:


  1. Login as the Oracle software owner user (oracle).
  2. Check if the rdbms/demo directory is copied to ORACLE_BASE_HOME.

    $ ls -l -d $(orabasehome)/rdbms/demo
  3. If the rdbms/demo directory has not been copied, then create it and copy it.

    $ mkdir -p $(orabasehome)/rdbms
  4. $ cp -r $ORACLE_HOME/rdbms/demo $(orabasehome)/rdbms/demo

Similarly, copy all the demo directories listed earlier from ORACLE_HOME to ORACLE_BASE_HOME.


Creating Symbolic Links

You must create symbolic links for the odbc/demo, precomp/demo, rdbms/demo, and xdk/demo demodirectories.

For rdbms/demo, replace $ORACLE_HOME/rdbms/demo with a symbolic link to the copy.

  1. Ensure that the symbolic link does not already exist.

    $ ls -l -d $ORACLE_HOME/rdbms/demo
  2. If $ORACLE_HOME/rdbms/demo is still the original demo directory, rename it and replace it with the symbolic link.

    $ cd $ORACLE_HOME/rdbms
  3. $ mv demo demo.installed
  4. $ ln -s $(orabasehome)/rdbms/demo $ORACLE_HOME/rdbms/demo

For odbc/demo, replace $ORACLE_HOME/odbc/demo with a symbolic link to the copy.

  1. Ensure that the symbolic link does not already exist.

    $ ls -l -d $ORACLE_HOME/odbc/demo
  2. If $ORACLE_HOME/odbc/demo is still the original demo directory, rename it and replace it with the symbolic link.

    $ cd $ORACLE_HOME/odbc
  3. $ mv demo demo.installed
  4. $ ln -s $(orabasehome)/odbc/demo $ORACLE_HOME/odbc/demo

For precomp/demo, replace $ORACLE_HOME/precomp/demo with a symbolic link to the copy.

  1. Ensure that the symbolic link does not already exist.

    $ ls -l -d $ORACLE_HOME/precomp/demo
  2. If $ORACLE_HOME/precomp/demo is still the original demo directory, rename it and replace it with the symbolic link.

    $ cd $ORACLE_HOME/precomp
  3. $ mv demo demo.installed
  4. $ ln -s $(orabasehome)/precomp/demo $ORACLE_HOME/precomp/demo

The xdk/demo directory requires a symbolic link at $ORACLE_HOME/xdk/include pointing to $(orabasehome)/xdk/include after you copy the xdk/demo directory.

  1. Ensure that the symbolic link does not already exist:
    $ ls -l -d $ORACLE_HOME/xdk/include
  2. If the symbolic link does not exist, then, run the following command:

    $ ln -s $ORACLE_HOME/xdk/include $(orabasehome)/xdk/include

Note:

In the plsql/demo directory, ncmpdemo.sqlis unusable in read-only mode.


Copying the init.ora File

Copy the init.ora file from ORACLE_HOME to ORACLE_BASE_HOME.

  1. Login as the Oracle software owner user (oracle).
  2. Check if the init.ora file exists in ORACLE_BASE_HOME.

    $ ls $(orabasehome)/init.ora 

    If an init.ora file exists in ORACLE_BASE_HOME, then update this init.ora file to be in-sync with the$ORACLE_HOME/init.ora file.
  3. If the init.ora file does not exist in ORACLE_BASE_HOME, then copy it from ORACLE_HOME.

    $ cp $ORACLE_HOME/init.ora $(orabasehome)/init.ora





Sunday, October 5, 2025

Execution Plan & Statistics in Oracle SQL

 

 Execution Plan & Statistics in Oracle SQL

An in-depth look at SQL query diagnosis and tuning


Execution Plan

The Execution Plan shows the SQL optimizer's query execution path. Execution Plan output is generated using EXPLAIN PLAN and DBMS_XPLAN.

Statistics

The statistics are recorded by the server when your statement executes and indicate the system resources required to execute your statement. The results include the following statistics.

Database Statistic Name

Description

recursive calls

Number of recursive calls generated at both the user and system level. Oracle Database maintains tables used for internal processing. When Oracle Database needs to make a change to these tables, it internally generates an internal SQL statement, which in turn generates a recursive call.

db block gets

Number of times a CURRENT block was requested.

consistent gets

Number of times a consistent read was requested for a block

physical reads

Total number of data blocks read from disk. This number equals the value of "physical reads direct" plus all reads into buffer cache.

redo size

Total amount of redo generated in bytes

bytes sent through Oracle Net Services to client

Total number of bytes sent to the client from the foreground processes.

bytes received through Oracle Net Services from client

Total number of bytes received from the client over Oracle Net.

Oracle Net Services round-trips to/from client

Total number of Oracle Net messages sent to and received from the client

sorts (memory)

Number of sort operations that were performed completely in memory and did not require any disk writes

sorts (disk)

Number of sort operations that required at least one disk write

rows processed

Number of rows processed during the operation

The client referred to in the statistics is SQL*Plus. Oracle Net refers to the generic process communication between SQL*Plus and the server, regardless of whether Oracle Net is installed. You cannot change the default format of the statistics report.

In Oracle, Recursive Calls are internal SQL statements that the database generates automatically to perform its own housekeeping tasks.

They are not issued by the user directly, but by Oracle itself when it needs to maintain data dictionary tables or perform background operations.

Examples of when recursive calls happen:

  • Creating or modifying database objects (tables, indexes, views, etc.)
  • Managing space in segments (e.g., extending a table or index)
  • Maintaining internal data dictionary tables
  • Executing PL/SQL blocks that internally issue SQL queries

Why it matters:

  • A normal amount of recursive calls is expected in any Oracle workload.
  • Excessive recursive calls often indicate:
    • Inefficient application code (too many DDLs or dynamic SQL)
    • Lack of bind variables, leading to many hard parses
    • Repeated queries against data dictionary views (like ALL_TABLES, DBA_USERS)

DBA Action: If recursive calls are unusually high, check the Top SQL report in AWR/Statspack to identify the source, and tune SQL or reduce unnecessary data dictionary access.

 

What makes “db block gets” too high?

  • Large number of full table scans with updates/deletes.
  • Poor index usage, causing row lookup with excessive block visits.
  • Hot blocks (many sessions contending for the same block).
  • Inefficient application logic updating many rows repeatedly.

 

 

 

 

 

How to optimize / tune

  1. SQL Tuning
    • Ensure queries use the right indexes (avoid unnecessary full scans).
    • Rewrite SQL to minimize row-by-row updates (use bulk operations if possible).
  2. Reduce Hot Block Contention
    • Spread inserts/updates across multiple blocks (use reverse key indexes or hash partitioning if appropriate).
    • Use sequence caching or multiple sequences to avoid all inserts hitting the same index block.
  3. Monitor Ratio
    • Compare db block gets vs consistent gets:
      • In OLTP, consistent gets should normally be higher.
      • If db block gets dominates, review workload for excessive modifications.

 

Rule of thumb for DBA attention:

  • If db block gets is high relative to consistent gets, investigate SQL execution and potential hot block contention.

 

Consistent gets vs. Physical Reads

Consistent Gets

  • Definition: Number of times Oracle accessed a block in consistent mode (read-only, possibly using undo data to provide a read-consistent image).
  • Happens in memory (buffer cache).
  • Reflects how often queries are satisfied without going to disk.
  • Higher is usually better → means most queries are resolved from cache.

 Optimization for Consistent Gets

  1. Tune SQL to use indexes efficiently (fewer block visits).
  2. Reduce unnecessary large scans (use partitions, filters).
  3. Ensure sufficient buffer cache so frequently accessed blocks remain cached.
  4. Rewrite queries to reduce repetitive lookups of the same data.

 

 Physical Reads

  • Definition: Number of blocks read from disk into buffer cache because they were not already cached.
  • Much slower than consistent gets, since disk I/O is involved.
  • High values usually indicate insufficient memory, poor SQL access paths, or large scans.

Optimization for Physical Reads

  1. Increase DB_CACHE_SIZE (more memory for buffer cache).
  2. Use KEEP pool for frequently accessed small lookup tables.
  3. Tune SQL to avoid unnecessary full table scans.
  4. Use indexes to minimize disk I/O.
  5. Consider partitioning for very large tables to reduce scanned blocks.
  6. In Exadata: enable Smart Scan to offload reads.

 

Relationship

  • Ideally, Oracle should satisfy most reads via consistent gets (memory) and minimize physical reads (disk).
  • A high consistent gets : physical reads ratio is a good sign of cache efficiency.
    • Example: If consistent gets = 1,000,000 and physical reads = 10,000 → ratio = 100:1 (good).
    • If ratio is low (<10:1), check memory sizing and SQL plans.
    •  

 DBA Rule of Thumb:

  • Consistent Gets High → Good (memory hit rate high).
  • Physical Reads High → Needs tuning (SQL or memory).

What is Redo Size?

  • It represents the total amount of redo entries (in bytes) generated in the redo log buffer and written to the redo log files.
  • Redo is required for data recovery, so every change to a data block (INSERT, UPDATE, DELETE, DDL) must generate redo.
  • Even some SELECTs (that create temporary segments) may generate redo.

 

Why Redo Size Matters

  • High redo generation increases:
    • Redo log I/O (LGWR writes more frequently).
    • Archiving overhead (in ARCH or Data Guard).
    • Network traffic (in RAC or Data Guard).
  • Excessive redo means the system is doing too many changes or inefficient modifications.

 

Causes of High Redo Size

  1. Large batch DML operations (bulk UPDATE/DELETE/INSERT).
  2. Indexes on heavily updated tables (each index update generates redo).
  3. Unnecessary commits in loops (commit frequently = more redo header overhead).
  4. Hot tables receiving massive concurrent DML.
  5. Data loads using conventional path (INSERT … VALUES / SELECT).
  6. Logging mode set to default (redo is always generated).

 

How to Control / Minimize Redo Size

  1. Use Direct-Path Inserts
    • INSERT /*+ APPEND */ or SQL*Loader direct path to bypass redo (in NOLOGGING mode).
    • Best for bulk loads where recovery of intermediate steps isn’t critical.
  2. Use NOLOGGING / UNRECOVERABLE Options (with caution!)
    • For objects like indexes, materialized views, and temporary tables.
    • Reduces redo, but means you cannot recover that object via redo after failure.
  3. Minimize Unnecessary Indexes
    • Each index on a table adds extra redo during DML. Keep only required indexes.
  4. Batch and Commit Strategy
    • Avoid committing row by row. Use larger batch commits.
    • Example: Commit every 10k rows instead of every row.
  5. Use Temporary Tables (Global Temporary Tables)
    • Operations on GTT generate little or no redo (only undo).
  6. Partitioning
    • Reduce redo during data maintenance by operating on smaller partitions.
  7. Application Tuning
    • Avoid unnecessary updates (e.g., updating a column to the same value).
    • Use MERGE instead of separate INSERT/UPDATE when applicable.

 

DBA Rule of Thumb

  • Redo size should scale with business workload.
  • Sudden spikes in redo size = usually due to a bad SQL or massive DML job.
  • Regularly check in AWR/Statspack reports → "Redo size per transaction" → to detect inefficient application logic.

 

 Sorts (Memory)

  • A sort operation that can be completed entirely in PGA (Program Global Area).
  • Fast, because data is kept in memory.
  • Examples:
    • ORDER BY, GROUP BY, DISTINCT, UNION, MERGE JOIN, index builds.
  • Tracked in Oracle statistics as sorts (memory).

 Good sign → most sorts should complete in memory.

 

 Sorts (Disk)

  • When the sort cannot fit into available PGA memory (workarea), Oracle spills data into temporary tablespace (TEMP).
  • Disk sorts are much slower due to I/O.
  • Tracked as sorts (disk) in Oracle statistics.

Bad sign if frequent → indicates insufficient memory or badly written queries.

 

Causes of High Sorts (Disk)

  1. Insufficient PGA memory (too small PGA_AGGREGATE_TARGET or PGA_AGGREGATE_LIMIT).
  2. Poor SQL design requiring unnecessary or large sorts.
  3. Lack of indexes → forcing large sorting operations.
  4. Too many concurrent sorts exhausting memory.
  5. Large reporting/analytic queries with ORDER BY, GROUP BY, DISTINCT.

 

How to Minimize Disk Sorts

  1. Increase PGA Memory
    • Use PGA_AGGREGATE_TARGET (or MEMORY_TARGET/MEMORY_MAX_TARGET) to allocate more memory.
    • For Oracle 12c+, PGA_AGGREGATE_LIMIT prevents runaway usage, so tune accordingly.
  2. Use Workarea Size Policy AUTO
    • Let Oracle automatically size sort/hash areas based on workload.
  3. Optimize SQL
    • Avoid unnecessary ORDER BY or DISTINCT.
    • Use indexes to avoid large sorts.
    • Rewrite queries with analytic functions to reduce temporary sorting.
  4. Use TEMP Tablespace Efficiently
    • Ensure TEMP has enough space to handle required disk sorts.
    • Monitor v$tempseg_usage for active temp usage.
  5. Batch Processing
    • Break very large sorts into smaller chunks if possible.
  6. Parallel Query Caution
    • Parallel operations can explode sort memory requirements and push more to disk.

 

🔹 DBA Rule of Thumb

  • Sorts (memory) >> Sorts (disk) → healthy system.
  • If sorts (disk) is high:
    • Check PGA_AGGREGATE_TARGET sizing.
    • Review top SQL for bad query design.
    • Check TEMP usage (shouldn’t grow excessively unless queries are poorly tuned).

 

Sorting in PGA (Memory Sorts)

  • If the sort fits entirely in PGA (workarea), it does not generate redo, because it’s private to the session.
  • Example: A query with ORDER BY that completes in memory.
  • Only undo may be generated if Oracle needs to construct read-consistent versions of blocks — but redo is not generated for in-memory sorting.

 

Sorting in TEMP Tablespace (Disk Sorts)

  • When a sort spills to TEMP, Oracle writes to tempfiles.
  • Tempfiles are not redo-logged (no redo generated).
  • This is by design: tempfiles can be recreated, and their contents are not needed for recovery.

 

But Sorting Can Generate Redo in Some Cases

  1. Index Creation / Rebuild
    • Oracle sorts keys before writing them to the index structure.
    • The index blocks being created do generate redo (unless you use NOLOGGING).
  2. Global Temporary Tables with ON COMMIT PRESERVE ROWS
    • Depending on settings, some redo may be generated for metadata/undo, but not for the bulk sort data.
  3. Operations Involving Permanent Segments
    • If the sort result is materialized into a permanent table (e.g., CREATE TABLE AS SELECT … ORDER BY), redo will be generated for populating the table.

 

Rule of Thumb

  • Normal SQL sorts (memory or temp) → No redo.
  • DDL operations (index build, CTAS, MV refresh) → Yes, redo generated (unless NOLOGGING).

 

Tracing Statements for Performance Statistics and Query Execution Path

If the SQL buffer contains the following statement:

SQL> SELECT E.LAST_NAME, E.SALARY, J.JOB_TITLE

FROM EMPLOYEES E, JOBS J

WHERE E.JOB_ID=J.JOB_ID AND E.SALARY>12000;

The statement can be automatically traced when it is run:

 

SET AUTOTRACE ON

/

Example: Tracing Statements Without Displaying Query Data

To trace the same statement without displaying the query data, enter:

SET AUTOTRACE TRACEONLY

/

About Collecting Timing Statistics

Use the SQL*Plus TIMING command to collect and display data on the amount of computer resources used to run one or more commands or blocks. TIMING collects data for an elapsed period of time, saving the data on commands run during the period in a timer.

To delete all timers, enter CLEAR TIMING.

 

Tracing Parallel and Distributed Queries

When you trace a statement in a parallel or distributed query, the Execution Plan output depends on the statement you use.

 

Example: Tracing Statements With Parallel Query Option

To trace a parallel query running the parallel query option:

create table D2_t1 (unique1 number) parallel (degree 6);

create table D2_t2 (unique1 number) parallel (degree 6);

create unique index d2_i_unique1 on d2_t1(unique1);

set long 500 longchunksize 500

SET AUTOTRACE ON EXPLAIN

SELECT /*+ INDEX(B,D2_I_UNIQUE1) USE_NL(B) ORDERED */ COUNT (A.UNIQUE1)

FROM D2_T2 A, D2_T1 B

WHERE A.UNIQUE1 = B.UNIQUE1;

Execution Plan

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

Plan hash value: 107954098

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

| Id  | Operation                 | Name    | Rows |Bytes| Cost(%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |

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

|   0 | SELECT STATEMENT   |         |    1 |  26 |    1   (0)| 00:00:01 |        |      |            |

|   1 |SORT AGGREGATE    |         |    1 |  26 |           |          |        |      |            |

|   2 |PX COORDINATOR   |         |      |     |           |          |        |      |            |

|   3 |PX SEND QC (RANDOM)    | :TQ10001|    1 |  26 |           |          |  Q1,01 | P->S | QC (RAND)  |

|   4 |SORT AGGREGATE   |         |    1 |  26 |           |          |  Q1,01 | PCWP |            |

|   5 |NESTED LOOPS |         |    1 |  26 |    1   (0)| 00:00:01 |  Q1,01 | PCWP |            |

|   6 |PX RECEIVE    |         |      |     |           |          |  Q1,01 | PCWP |            |

|   7 | PX SEND BROADCAST  | :TQ10000|      |     |           |          |  Q1,00 | P->P | BROADCAST  |

|   8 |  PX BLOCK ITERATOR |         |    1 |  13 |    0   (0)| 00:00:01 |  Q1,00 | PCWC |            |

|   9 | TABLE ACCESS FULL| D2_T2   |    1 |  13 |    0   (0)| 00:00:01 |  Q1,00 | PCWP |            |

|  10 | PX BLOCK ITERATOR   |         |    1 |  13 |    2   (0)| 00:00:01 |  Q1,01 | PCWC |            |

|* 11 | TABLE ACCESS FULL  | D2_T1   |    1 |  13 |    2   (0)| 00:00:01 |  Q1,01 | PCWP |            |

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

 Predicate Information (identified by operation id):

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

  11 - filter("A"."UNIQUE1"="B"."UNIQUE1")

 Note

-----

   - dynamic sampling used for this statement

 

Example: To monitor disk reads and buffer gets.

SET AUTOTRACE TRACEONLY STATISTICS

The following shows typical results:

Statistics

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

        467  recursive calls

         27  db block gets

        147  consistent gets

         20  physical reads

       4548  redo size

        502  bytes sent via Oracle Net Services to client

        496  bytes received via Oracle Net Services from client

         2  Oracle Net Services roundtrips to/from client

         14  sorts (memory)

          0  sorts (disk)

          1  rows processed

 

If consistent gets or physical reads are high relative to the amount of data returned, it indicates that the query is expensive and needs to be reviewed for optimization. For example, if you are expecting less than 1,000 rows back and consistent gets is 1,000,000 and physical reads is 10,000, further optimization is needed.

Note

You can also monitor disk reads and buffer gets using V$SQL or TKPROF.

 

Execution Plan Output in Earlier Databases

Execution Plan output from Oracle Database 9i Release 2 (9.2) or earlier is different.

Each line of the Execution Plan has a sequential line number. SQL*Plus also displays the line number of the parent operation.

The Execution Plan consists of four columns displayed in the following order:

Column Name

Description

ID_PLUS_EXP

Shows the line number of each execution step.

PARENT_ID_PLUS_EXP

Shows the relationship between each step and its parent. This column is useful for large reports.

PLAN_PLUS_EXP

Shows each step of the report.

OBJECT_NODE_PLUS_EXP

Shows database links or parallel query servers used.

The format of the columns may be altered with the COLUMN command.

For example, to stop the PARENT_ID_PLUS_EXP column being displayed, enter

COLUMN         PARENT_ID_PLUS_EXP    NOPRINT

The Execution Plan output is generated using the EXPLAIN PLAN command.

When you trace a statement in a parallel or distributed query, the Execution Plan shows the cost-based optimizer estimates of the number of rows (the cardinality). In general, the cost, cardinality and bytes at each node represent cumulative results.

For example, the cost of a join node accounts for not only the cost of completing the join operations, but also the entire costs of accessing the relations in that join.

Lines marked with an asterisk (*) denote a parallel or remote operation. Each operation is explained in the second part of the report.

The second section of this report consists of three columns displayed in the following order

Column Name

Description

ID_PLUS_EXP

Shows the line number of each execution step.

OTHER_TAG_PLUS_EXP

Describes the function of the SQL statement in the OTHER_PLUS_EXP column.

OTHER_PLUS_EXP

Shows the text of the query for the parallel server or remote database.

The format of the columns may be altered with the COLUMN command.

 

Oracle Database Performance: Avoiding Unnecessary Table Scans

Oracle Database Performance: Avoiding Unnecessary Table Scans One of the common recommendations in database performance tuning is to avoid...