Table of Contents
- Introduction to Oracle Database Architecture
- Logical structures vs. physical structures
- Understanding Oracle Instance (Part 1)
- Understanding Oracle Instance (Part 2)
- Oracle Storage Hierarchy (Part 1)
- Oracle Storage Hierarchy (Part 2) — Container Database (CDB)
- Oracle Storage Hierarchy (Part 3) — System Files
- Processes and interactions (Part 1)
- Processes and interactions (Part 2) — Mandatory and optional background processes
- Overview of memory structures and SGA (Part 1)
- Overview of Memory Structures and SGA (Part 2) — Query Execution Flow
- Role of Program Global Area — PGA (Part 1)
- Role of Program Global Area — PGA (Part 2)
- Shared memory areas for optimization (Part 1) — Shared Pool
- Shared memory areas for optimization (Part 2) — Shared Pool in detail
- Shared memory areas for optimization (Part 3) — Database Buffer Cache
- Shared memory areas for optimization (Part 4) — Large Pool
- Memory allocation methods
- Demo — Memory Monitoring and Troubleshooting
- Introduction to background processes
- Redo Log Writer and Data Recovery
- Recoverer Process (RECO)
- Recovery Writer Process (RVWR)
- Checkpoints and archiving process
- Database Writer Process (DBWn)
- Archiver Process (ARCn)
- Flashback Data Archiver Process (FBDA)
- Listener Processes and dynamic recording
- Process Monitoring and Diagnostics (Part 1)
- Process monitoring and diagnostics (Part 2) — AWR and ADR
- Introduction to logical storage
- Specialized tablespaces (SYSTEM, SYSAUX)
- UNDO Tablespace
- Logical Storage Management Tools
- Role and structure of Redo Logs
- Importance of Control Files
- Archived Redo Logs vs Online Redo Logs
- Configuration of Redo Logs and multiplexing of Control Files
- Monitoring and Troubleshooting Control Files
1. Oracle Database Architecture Fundamentals
Introduction to Oracle Database Architecture
Oracle Database 19c is a complex relational database whose architecture is documented in an official 40-page Oracle technical document. Understanding this architecture is essential for any professional working with Oracle, whether new or experienced.
Key Components of Oracle Database 19c
The fundamental components of the Oracle Database 19c architecture are:
| Component | Description |
|---|---|
| Instance Database | Responsible for interacting with the database and processing queries. Includes memory structures and background processes. |
| Physical Storage Structures | Includes data files, control files and redo log files. |
| Logical Storage Structures | Includes tablespaces, segments, extents and blocks. |
| Memory Structures | Includes SGA (System Global Area) and PGA (Program Global Area). |
| Processes | Includes client processes, server processes, and background processes. |
Physical Storage Structures
- Data files: store the actual database data.
- Control files: contain metadata about the database (physical structure, file location, etc.).
- Redo log files: save transaction history for recovery purposes.
Logical Storage Structures
- Tablespaces: logical groupings of data files.
- Segments: logical units representing objects (tables, indexes, etc.).
- Extents: contiguous blocks of storage within a segment.
- Blocks: Smallest Oracle storage unit.
Memory Structures
- System Global Area (SGA): Shared memory area for caching data and executing SQL queries.
- Program Global Area (PGA): memory allocated by user process for session-specific operations.
Processes
- Client processes: initialize database operations.
- Server processes: process requests from client processes.
- Background processes: manage critical functions such as writing to disk, log management and crash recovery.
Logical structures vs. physical structures
Oracle Database 19c organizes and manages data through two types of structures: logical structures and physical structures.
Logical structures
Logical structures are abstract representations of how data is organized and presented to users. They allow users and applications to interact with data without worrying about its physical location or storage mechanism.
| Logical structure | Description |
|---|---|
| Tablespace | Logical container for grouping related objects. Each tablespace is associated with one or more physical data files. |
| Segment | Storage allocated for database objects like tables or indexes. |
| Extent | Contiguous blocks of storage contained within a segment. |
| Block | Smallest Oracle storage unit. Each block corresponds to a specific number of bytes in physical storage. |
Physical structures
Physical structures represent how data is stored on disk. These structures are managed by the Oracle instance to ensure reliable access and safe storage of data.
| Physical structure | Description |
|---|---|
| Data files | Store real user data, organized in blocks. |
| Redo log files | Save changes to the database for recovery purposes. |
| Control files | Contain metadata about the physical structure of the database, including the locations of data files and log files. |
Characteristics comparison
| Criterion | Physical structures | Logical structures |
|---|---|---|
| Nature | Actual data storage on disk | Abstract Data Representations |
| Visibility | Transparent for users, managed by the base | Used by users and applications |
| Components | Data files, redo log files, control files | Tablespaces, segments, extents, blocks |
| Focus | Data storage and retrieval, low-level disk operations | Logical organization of data, high-level abstractions |
The relationship between the two types of structures is as follows: logical structures rely on physical structures. A tablespace, for example, corresponds to one or more data files on disk. This abstraction allows administrators to manage data logically, without worrying directly about physical files.
Understanding Oracle Instance (Part 1)
Setting Oracle Instance
An Oracle Instance combines memory structures and background processes that manage database operations. It acts as an intermediary between users and the physical storage of data in the database.
Oracle Instance Components:
- System Global Area (SGA): Shared memory used for data caching, SQL execution, and other shared resources.
- Program Global Area (PGA): session-specific memory allocated for user processes.
- Background processes: responsible for tasks such as writing data to disk, managing logs and recovering data in the event of a failure.
Database vs. Instance
The database itself is a set of physical files on disk that store the actual data. It includes data files, control files and redo log files. A database can exist independently of an instance, but it cannot be accessed or managed without it.
Client login flow
The process of connecting a client application to Oracle Database is as follows:
- The client application prepares a connect packet: a request to connect to the database server (reporting tool, web application, script, etc.).
- Listener receives the request: The listener is like a receptionist of the database server — it constantly waits for incoming connection requests, validates the request and establishes the connection.
- Connecting to Oracle Instance: Once validation is complete, the listener connects the client application to the database instance.
- Creation of a server process: inside the instance, a server process is created specifically for the client application. This server process is the personal representative of the database for the client.
- Data access: the process server interacts with the LMS and physical storage structures to respond to client requests.
Understanding Oracle Instance (Part 2)
Oracle Instance Detailed Components
The Oracle Instance can be thought of as a combination of memory and processes. Its key components are:
System Global Area (SGA)
The LMS functions as a giant workspace where data is cached, queries are optimized, and operations are managed to improve performance. For example, when a query is running, the LMS can temporarily store parts of the data so that repeated queries can be processed more quickly.
Program Global Areas (PGA)
Unlike the SGA which is shared, the PGAs are private memory areas for each process server. Every time a client application connects to the database, it triggers the creation of a server process to handle that specific connection. The PGA is where this server process keeps its working data: variables, session-specific information, and temporary results while SQL statements execute.
Background processes
These are special processes that run automatically to support the database. They function as maintenance workers who keep everything running. For example:
- Some background processes write data from memory to the database.
- Others clean up old data or make sure transactions are properly backed up.
- These processes are essential for maintaining the LMS, managing connections, and ensuring the database operates efficiently.
Server processes
Server processes connect all of these components together. When a client sends SQL queries, the server process processes the requests and interacts with the database itself, which stores the actual data (data files, tables, indexes, etc.).
Oracle Storage Hierarchy (Part 1)
Oracle Database uses a layered hierarchy to manage data storage. Each layer provides an abstraction that simplifies data management while allowing fine-grained control when necessary.
The three levels of the hierarchy
Data Files (niveau physique)
└── Tablespaces (niveau logique)
└── Segments
└── Extents
└── Blocks (plus petite unité)
Data Files
Data files are the physical files on disk that store the actual database data. Each database includes one or more data files. Oracle manages data files automatically, but database administrators (DBAs) can configure them as needed (resizing, etc.).
Tablespaces
Tablespaces are logical storage units that group related files together. They provide a layer of abstraction on top of data files. A tablespace can span multiple data files, and each data file belongs to a single tablespace.
Common tablespace types:
| Tablespace | Role |
|---|---|
| SYSTEM | Stores the data dictionary and critical database metadata. |
| SYSAUX | Contains the auxiliary components of the database (statistics, performance metadata). |
| USERS | Contains objects created by users (tables, indexes). |
| UNDO | Stores undo data for transaction rollback and recovery. |
| TEMP | Temporary tablespace for large sort operations. |
Segments
Segments are the space allocated in one or more extents within a tablespace.
Segment types:
- Table segments: store the data of a table.
- Index segments: store the data of an index.
- Undo segments: Store undo data for active transactions.
- Temporary segments: used for temporary sort operations.
Extents
An extent is a contiguous set of Oracle blocks within a segment. When a segment needs more space, Oracle allocates an extent. By allocating space in extents rather than individual blocks, Oracle ensures that related data remains physically close on disk, which improves performance.
Blocks
Blocks are the smallest unit of storage in Oracle Database. The size of a block can vary, but is typically around 8 KB. A block corresponds to a specific number of bytes in physical storage and is the fundamental read/write granularity.
Oracle Storage Hierarchy (Part 2) — Container Database (CDB)
Architecture of a Container Database (CDB)
Oracle Database 19c organizes its data files in the context of a Container Database (CDB). This architecture includes:
1. CDB Root (CDB$ROOT)
The root container contains a set of data files shared between all databases in the container:
- SYSTEM data file
- SYSAUX data file
- TEMP data file
- UNDO data file
- USERS data file
These files form the foundation for all other databases in the container.
2. Seed Pluggable Database (PDB$SEED)
This is a special Pluggable Database (PDB) preconfigured by Oracle. It works like a template: when you want to create a new database, the PDB seed is copied to form a new PDB. The PDB seed has its own set of data files.
3. Regular Pluggable Databases (PDBs)
These are the actual databases that users interact with. Each PDB is like an independent database inside the container with its own data files:
- SYSTEM and SYSAUX data files (metadata and functionalities)
- TEMP for temporary operations
- USERS for user-created tables and objects
- Optional UNDO data file for PDB-specific rollback operations
Although each PDB is independent, they share all data in the root container, allowing centralized management and reduced redundancy.
4. Application Container
Special container type designed for applications. If multiple PDBs run the same application, an application container can be used to manage objects and data shared between these PDBs, further reducing redundancy.
Oracle Storage Hierarchy (Part 3) — System Files
Essential files for database startup
The files absolutely essential to start Oracle Database are:
| File | Role |
|---|---|
| Control files | Database blueprint. Following is the structure of the database including file locations, log sequences, and more. Oracle continually updates them to ensure consistency. |
| Parameter file | Contains database configuration settings (memory allocation, process limits, etc.). Acts as a set of instructions that Oracle follows during startup. |
| Online redo log files | Crucial for transaction management. Records every change made to the database, allowing Oracle to recover from unexpected shutdowns or crashes. |
Automatic Diagnostic Repository (ADR)
The ADR is Oracle’s central location for storing diagnostic data: error logs, trace files and incidents. If something goes wrong, ADR is the starting point for troubleshooting and identifying the root cause.
Other important files
| File | Role |
|---|---|
| Archive redo log files | Old copies of redo log files automatically archived by Oracle. Used mainly for recovery operations, allowing changes to be replayed during a recovery. |
| Password file | Authenticates privileged users who remotely connect to the database. |
| Backup files | Essential to the backup and recovery strategy, allowing a database to be restarted in the event of a disaster. |
Processes and interactions (Part 1)
The three categories of Oracle processes
An Oracle Instance relies on three types of processes to interact with users:
1. Client processes
Initiated by user applications or tools to interact with the database. Examples: SQL*Plus, applications using the Oracle Client library. They send requests to the server process and receive the results (query outputs) back. A process customer is like a customer who places an order at a service counter.
2. Server processes
Process customer requests and interact with the database on their behalf. They operate in two modes:
- Dedicated server mode: one process server per process client.
- Shared server mode: several client processes share a pool of server processes.
Server processes parse and execute SQL statements, retrieve or modify database data, and return query results or execution status to the client process. A process server is like a store clerk who fulfills customer orders.
3. Background processes
Critical processes that keep the database running. The main ones are:
| Background Process | Role |
|---|---|
| Database Writer (DBWn) | Writes dirty data blocks from the SGA to data files on disk. |
| Log Writer (LGWR) | Writes redo log entries from memory to online redo log files for recovery. |
| System Monitor (SMON) | Handles instance recovery when booting after a crash. |
| Process Monitor (PMON) | Cleans up resources after a user or server process failure. |
| Checkpoint (CKPT) | Signals the Database Writer to synchronize data in memory with data on disk. |
Processes and interactions (Part 2) — Mandatory and optional background processes
Mandatory processes
These processes are essential for any Oracle Database to function. They perform critical tasks to keep the database running smoothly and reliably.
| Process | Acronym | Role |
|---|---|---|
| Process Monitor | PMON | Cleans up failed or terminated user sessions. Frees resources (blocks, memory) for other sessions. |
| System Monitor | SMON | Recovers the database in case of crash. Performs cleanup tasks and frees space in tablespaces. |
| Database Writer | DBWn | Writes dirty data blocks from the database buffer cache to physical data files on disk. Maintains synchronization between memory and storage. |
| Log Writer | LGWR | Ensures every transaction is recorded for retrieval. |
| Checkpoint | CKPT | Signals the Database Writer to synchronize data in memory with data on disk, creating a consistent recovery point. |
| Listener Registration | LREG | Helps the Oracle Instance communicate with the listener process, ensuring that client requests can reach the correct instance. |
| Manageability Monitor | MMON | Collects performance statistics for monitoring and tuning. Supports tools like Automatic Workload Repository (AWR). |
| Manageability Monitor Lite | MMNL | Works alongside MMON to write performance statistics to disk. |
| Recover | RECO | Manages distributed transactions. |
Optional processes
These processes are not required for basic operations, but are extremely useful for advanced functionality.
| Process | Role |
|---|---|
| Archive (ARCn) | Archive filled redo log files to a secure destination. Essential in archive log mode. |
| Job Queue Coordinator | Manages scheduled tasks in the database. |
| Flashback Data Archiver | Archives historical versions of data for flashback operations. |
2. Memory Structures in Oracle Database
Overview of Memory Structures and SGA (Part 1)
The System Global Area (SGA)
The SGA is a shared memory area that stores data and control information for an Oracle Instance. It is allocated at instance startup and is used by all server processes and background processes.
LMS Key Responsibilities:
- Caching frequently accessed data and SQL execution plans.
- Reduced disk I/O while maintaining essential data in memory.
- Managing communication between instance processes.
Analogy: The LMS is like the reading room of a library where the most frequently accessed books (data) and reference guides (execution plans) are kept accessible for multiple readers (processes).
LMS Components
| Component | Role |
|---|---|
| Database Buffer Cache | Stores copies of data blocks read from data files. Frequently accessed data remains there to reduce physical disk I/O. |
| Shared Pool | Caches SQL statements, execution plans, and PL/SQL code for reuse. Contains the library cache and the data dictionary cache. |
| Redo Log Buffer | Temporarily stores redo log entries describing changes to the database. Ensures data recovery by recording all transactions before they are written to disk. |
| Large Pool | Optional memory area for large memory allocations (shared server sessions, backup/restore operations, parallel I/O). |
| Java Pool | Used for session memory and Java code running in the Oracle JVM. |
| Streams Pool | Used by Oracle Streams for data capture and application operations. |
Shared Pool in detail
The Shared Pool has two major components:
- Library cache: stores parsed SQL and PL/SQL instructions, as well as execution plans. Allows reuse.
- Data dictionary cache: stores metadata about database objects (table definitions, data types, user privileges). Avoid repeated disk accesses for this information.
Overview of memory structures and SGA (Part 2) — Query execution flow
Traversing a query in the LMS
This is what happens in the LMS when a query is executed (for example, retrieving a list of orders from a customer):
Step 1 — Arrival in the Shared Pool
The request first arrives at the Oracle Instance. The Shared Pool is the first point of interaction:
- Oracle checks the SQL query cache of the shared pool to see if the same query has already been executed recently.
- Cache hit: If a match is found, Oracle reuses the cached execution plan, saving time and resources.
- Cache miss: If the query is not found, Oracle parses the query, generates a new execution plan and stores it in the shared pool for future use.
The shared pool data dictionary cache also validates table structures, column names, and user permissions related to the query.
Step 2 — Database Buffer Cache
- The buffer cache temporarily stores data blocks read from database files on disk.
- If the requested data is already in the cache buffer (following a previous request), it is served directly from memory — very fast operation.
- If the data is not in the buffer cache, Oracle retrieves it from disk and loads it into the cache for the current query and potential future queries.
- This design minimizes disk I/O because subsequent requests for the same data can be served directly from memory.
Step 3 — Complex operations (sort, aggregation)
If the query involves operations like sorts or aggregations, Oracle uses workspaces inside the LMS:
- For simple operations: the database buffer cache or the shared pool are sufficient.
- For complex operations: temporary memory areas in the large pool or the memoptimize pool can be used.
Step 4 — Redo Log Buffer
During query execution, any changes to the data (updates, inserts, deletes) are captured in the redo log buffer. This component temporarily stores these changes before they are written to disk by the Log Writer process.
Role of the Program Global Area — PGA (Part 1)
What is the PGA?
The Program Global Area (PGA) is a private memory region allocated for each server process or background process in Oracle Database. Unlike the SGA which is shared between all sessions, the PGA is dedicated to a single process and cannot be accessed by other processes. This design ensures that session-specific operations are fast, secure, and isolated.
PGA Key Features
1. Management of session-specific data
The PGA stores session-specific data: variables, cursors and work areas for SQL operations. For example, when executing a query, the PGA may contain intermediate results (rows being sorted or aggregated) before the final result is returned.
2. Sort operations
When queries involve sorting data (such as ordering results with ORDER BY), the PGA provides the memory space needed for sorting. If the sort operation exceeds the available PGA memory, Oracle dumps the data to the temporary tablespaces on disk. Having enough PGA memory minimizes disk operations and improves query performance.
3. Hash operations
The PGA plays a key role in managing hash operations, commonly used in joins and aggregations. For example, for a join between two large tables, the PGA provides the memory to construct the hash tables, thereby speeding up the join operation.
4. Session cursors
The PGA maintains session-specific cursors, which point to currently executing SQL statements. This allows efficient execution of repeated queries in the same session.
5. Work areas
These fields in the PGA are used for specific operations such as sorting, joining, and buffering data. They are dynamically allocated and deallocated as needed.
PGA memory management
PGA memory can be managed:
- Manually: via the
PGA_AGGREGATE_TARGETparameter. - Automatically: Oracle dynamically adjusts memory based on workload.
Role of the Program Global Area — PGA (Part 2)
Query execution flow in the PGA
This is how the PGA operates when a query is executed:
1. Receipt of the request
The client sends a query to Oracle Database. The server process receives and handles the request. When the process server is created to handle this request, a dedicated PGA is allocated to it.
2. Structure of the PGA
The PGA contains two main areas: the User Global Area (UGA) and the Private SQL Area.
User Global Area (UGA)
The UGA is responsible for storing session-specific information. Its components:
| Component | Role |
|---|---|
| Spell area | Used when the query involves sorting (ORDER BY, GROUP BY). |
| Hash area | Used when the query involves a hash join. Stores hash tables for efficient processing. |
| Bitmap merge area | Used if the query includes bitmap indexes. Handles merging and manipulation of bitmap data. |
| Session memory | Stores user-specific session variables (PL/SQL variables, session parameters). |
| OLAP pool | Used if the query involves OLAP (Online Analytical Processing) operations for advanced analytics or multi-dimensional queries. |
These three work areas (sort, hash, bitmap merge) dynamically allocate and deallocate memory as needed during execution, thus optimizing performance.
Private SQL Area
The Private SQL Area is where the actual details of query execution are handled. It has two subcomponents:
| Subcomponent | Description |
|---|---|
| Persistent area | Contains information needed for the entire lifetime of the query, such as cursor definitions and state information. |
| Runtime area | Contains temporary execution information, such as intermediate results and row pointers. Created when the query begins execution and freed at the end. |
Shared Memory Areas for Optimization (Part 1) — Shared Pool
Shared Pool Overview
Shared Memory Areas are part of the SGA and are used by all sessions connected to the database. Unlike PGA which is private to each session, Shared Memory Areas can be accessed simultaneously by multiple users and processes. This shared nature allows Oracle to reuse resources, avoid redundant calculations, and serve multiple users efficiently.
The Shared Pool — central command hub
The Shared Pool is like the central control hub of the database. It has two major components:
1. Library Cache
- Stores parsed SQL and PL/SQL statements and execution plans.
- When a query is executed, Oracle checks the library cache to see if the same query has already been processed.
- Soft parse: If a match is found, Oracle reuses the existing execution plan, avoiding parsing and optimization. Significantly reduces overload.
- Example: If multiple users run the same report, Oracle does not need to reprocess the query each time — it simply reuses the cached plan.
2. Data Dictionary Cache
- Stores metadata about database objects: table definitions, column data types, and user privileges.
- Instead of retrieving this information from disk each time, Oracle keeps it in memory for faster query validation and user permission checking.
- For example, if the query references a table called
orders, the data dictionary cache provides details like table columns, data types, and constraints.
Shared Memory Areas for Optimization (Part 2) — Shared Pool in Detail
Execution flow in Shared Pool
When a query is received by Oracle Database, the first stop in the memory hierarchy is the Shared Pool. This is where the database decides whether it can reuse existing resources or whether it needs to do additional work.
1. Checking the Library Cache
At the heart of the shared pool is a library cache which contains a shared SQL and PL/SQL area. The database checks the library cache to see if the same SQL or PL/SQL statement has already been executed:
- Soft parse: the instruction is already present → Oracle skips parsing and optimization. Saves time and CPU.
- Hard parse: the instruction is not found → a new entry is created and the query goes through parsing, optimization and execution plan generation.
2. Validation via the Data Dictionary Cache
Once the query is parsed, the database must validate its structure. The data dictionary cache contains metadata about objects (table definitions, column types, user permissions). This speeds up the validation process and ensures that the query follows database rules.
3. Server Result Cache
If the query involves repetitive calculations or operations, Oracle uses the server result cache to store the results of these calculations. It includes:
- SQL query results cache: Stores the results of frequently executed SQL queries.
- PL/SQL function results cache: stores the results of PL/SQL functions, avoiding repetitive calculations.
Shared Memory Areas for Optimization (Part 3) — Database Buffer Cache
The Database Buffer Cache
The database buffer cache is at the heart of Oracle’s performance optimization strategy. It temporarily stores copies of data blocks read from or written to the database.
Operating principle:
- When a query requests data, Oracle first checks the buffer cache.
- Cache hit: data is already present → served directly from memory (much faster than disk access).
- Cache miss: the data is not present → Oracle retrieves it from disk, places it in the cache buffer, then serves it to the query.
Buffer Pools
The database buffer cache is divided into several buffer pools:
| Buffer Pool | Description |
|---|---|
| Default buffer pool (8K) | Main pool where most data blocks are stored. Used for standard queries and operations. |
| Keep buffer pool | Designed to retain frequently accessed data blocks in memory for as long as possible. Example: lookup tables repeatedly accessed. |
| Recycle buffer pool | Used for rarely accessed data (large tables that are rarely used). Blocks in this pool are quickly overwritten to make room for new data. |
| Non-default buffer pools | Enables custom block sizes (2K, 4K, 16K, 32K), allowing Oracle to handle workloads with varying block size requirements. |
LRU List (Least Recently Used)
Once the data blocks are loaded into the buffer cache, they are managed using an LRU list:
- Frequently accessed blocks are moved to the “hot” end of the list, ensuring that they stay in memory longer.
- Less recently used blocks are moved to the “cold” end and can be replaced to make room for new data.
Shared Memory Areas for Optimization (Part 4) — Large Pool
The Large Pool
The Large Pool is an optional memory area of the SGA that provides memory for large allocations. Its main use cases are:
Dedicated Server Configuration
- Each client has its own dedicated process server.
- Ideal configuration for high priority, low concurrency workloads, where each client requires uninterrupted access to a server process.
Shared Server Configuration
- Multiple client applications share server resources, using a dispatcher to route requests to shared server processes.
- More efficient for environments with many simultaneous connections.
Operating mechanism with the Large Pool:
- Requests arrive in the request queue (orderly management, prevention of bottlenecks).
- Shared server processes monitor the request queue and take care of pending requests.
- The Large Pool dynamically allocates memory to handle these requests, ensuring that each server process gets the necessary resources.
- Once the data is retrieved from the database, it is temporarily stored in the I/O buffer area of the Large Pool before being sent to the client.
- The dispatcher retrieves the response from the response queue and sends it back to the client application.
Other areas of the Large Pool:
| Area | Description |
|---|---|
| Free memory | Dynamically allocated memory for active queries and operations. |
| RMAN backup/restore | Memory for backup and restore operations via Oracle Recovery Manager (RMAN). |
| Parallel query | Memory for parallel query operations. |
Memory allocation methods
Oracle Database provides two primary methods for managing memory: manual management and automatic management.
1. Manual Memory Management (MMM)
Manual memory management is the traditional approach. It requires that DBAs manually allocate memory to the different components of the SGA and PGA.
Configuration:
DBAs explicitly configure memory parameters:
| Parameter | Description |
|---|---|
DB_CACHE_SIZE | Database buffer cache size. |
SHARED_POOL_SIZE | Shared pool size. |
PGA_AGGREGATE_TARGET | Aggregated PGA target. |
Each component size is fixed according to the configured parameters. Depending on the setting, adjustments require either dynamic resizing or a database restart.
Advantages:
- Fine control: Precisely allocate memory where it is needed depending on the workload. For example, if the load involves many complex joins, more memory can be allocated to the PGA for sort operations.
- Predictability: By having full control, one can predict the behavior of the database under specific loads.
Disadvantages:
- Time-consuming: Manual memory configuration and tuning can be laborious, especially in environments with dynamic workloads.
- Misallocation Risk: If too much memory is allocated to one area and not enough to another, this can result in suboptimal performance. For example, allocating too much to the SGA can starve the PGA, slowing down session-specific tasks.
2. Automatic Memory Management (AMM)
Automatic memory management greatly simplifies memory administration. Oracle automatically manages memory distribution between the SGA and the PGA.
Automatic management modes:
| Fashion | Settings | Description |
|---|---|---|
| Automatic Shared Memory Management (ASMM) | SGA_TARGET | Oracle automatically manages the individual components of the LMS. |
| Automatic Memory Management (AMM) | MEMORY_TARGET, MEMORY_MAX_TARGET | Oracle automatically manages the total memory of the instance (SGA + PGA combined). |
Advantages of AMM:
- Simplicity: eliminates the need for manual configuration of each memory component.
- Adaptability: Oracle dynamically redistributes memory in response to workload changes. For example, if the workload changes from web server to intensive batch processing, Oracle automatically reallocates memory accordingly.
- Optimization: Oracle uses internal algorithms to ensure that memory is used efficiently.
Disadvantages:
- Less control: The administrator has less control over precise memory allocation.
- Unpredictable behavior: In some workload scenarios, automatic behavior may not be optimal.
Demo — Memory Monitoring and Troubleshooting
This section presents views and SQL queries used to monitor memory in Oracle Database.
Monitor overall SGA
The V$SGA view provides an overview of the total memory allocated to the SGA and its components (shared pool, buffer cache, large pool):
SELECT NAME, VALUE / (1024*1024) AS "MB"
FROM V$SGA;
This output shows the fixed and variable memory sections of the SGA.
Details of SGA memory usage by component
The V$SGASTAT view allows you to break down SGA memory usage by individual component:
SELECT POOL, NAME, BYTES / (1024*1024) AS "MB"
FROM V$SGASTAT
ORDER BY BYTES DESC;
The cache buffer generally appears at the top of the ranking.
Identify memory-intensive queries in the Shared Pool
SELECT SQL_TEXT, SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM
FROM V$SQL
ORDER BY SHARABLE_MEM DESC;
This query is used to identify SQL statements consuming excessive memory in the shared pool and to optimize them.
Diagnose Shared Pool Memory Usage
SELECT NAME, BYTES / (1024*1024) AS "MB"
FROM V$SGASTAT
WHERE POOL = 'shared pool'
ORDER BY BYTES DESC;
This query explicitly checks the memory usage of the different components of the shared pool and displays the components with the number of bytes used.
3. Oracle Database Process
Introduction to background processes
Oracle background processes run automatically to manage fundamental database operations. They function as specialized workers, each assigned to a specific task.
Database Writer Process (DBWn)
The Database Writer is responsible for writing dirty data blocks from the database buffer cache in memory to the data files on disk. This process allows data to be written in batches, reducing disk I/O and improving performance.
Disk write triggers:
- When the cache buffer is full.
- During checkpoints.
- When a certain threshold of dirty blocks is reached.
Log Writer Process (LGWR)
The Log Writer writes redo log entries from the redo log buffer to online redo log files on disk. Redo log entries record every change made to the database, ensuring that no committed transactions are lost.
Why LGWR is critical:
- In the event of a database crash, Oracle uses redo logs to recover committed transactions.
- The Log Writer ensures that transaction changes are logged before Oracle considers them successful.
Write triggers:
- Each time a COMMIT or ROLLBACK is sent.
- When the redo log buffer is one-third full.
- Before dirty blocks are written to disk.
System Monitor (SMON)
This process handles instance recovery when restarting a database instance after a crash. It also cleans up temporary segments that are no longer in use and coalesces free space into tablespaces.
Process Monitor (PMON)
The PMON cleans the resources after the failure of a user or server process: release of locks, cleaning of memory. It also notifies the listener so that new connections can be established.
Checkpoint Process (CKPT)
This process signals the Database Writer to synchronize data in memory with data on disk, creating a consistent recovery point. It also updates the control files and data files to indicate that a checkpoint has occurred.
Redo Log Writer and Data Recovery
Importance of the Log Writer Process (LGWR)
The Log Writer Process is one of the most important and critical components of Oracle Database. Understanding how it works is essential because it plays a vital role in data security, recoverability, and consistency, even in the face of unexpected failures.
Write flow during a transaction
This is what happens when running a query that modifies data:
1. Reception by the process server
The process server supports the SQL statement. Instead of writing the change directly to the data file on disk (which would be slow), Oracle writes the change to the buffer cache inside the SGA.
2. Creating a redo entry
In parallel, the server process writes a redo entry into the redo log buffer. A redo entry is a detailed record of the change: what was modified, which data block was affected and how to rebuild the change if necessary. This step ensures that even if the system crashes at this time, Oracle will be able to recover the change later.
3. Intervention of the Log Writer Process (LGWR)
The LGWR continuously monitors the redo log buffer. At key times (during a COMMIT, when the buffer is almost full, or every few seconds), it writes these entries to the redo log files on disk. These redo log files are stored in two important areas:
- Database area: location of regular redo logs.
- Fast Recovery Area: optimized for recovery and backup operations.
4. Commit and sustainability
The transaction is only considered committed once the redo entry has been securely written to the redo log files. This is how Oracle ensures data durability.
Integration with Oracle Data Guard
In advanced configurations using Oracle Data Guard for disaster recovery, an additional step is considered: the redo transport slave process transmits the redo data to the standby databases, thus maintaining their synchronization with the primary database.
Recoverer Process (RECO)
Role of the Recoverer Process
The Recoverer Process is a specialized background process that plays a critical role in maintaining data consistency in distributed databases. It is the database’s personal problem-solver, intervening when distributed transactions encounter unexpected problems.
Usage scenario
Let’s imagine a company with two interconnected Oracle Databases (database A and database B):
- A user executes a transaction that must be performed on both databases.
- The network connection between the two bases fails just after base A processes the update, but before base B can finish its game.
- Result: A partially completed transaction that has not been fully committed or rolled back.
RECO intervention:
- RECO detects the in-doubt transaction.
- It connects to the other database (base B) to determine whether the transaction should be committed or rolled back.
- If the other system confirms that the transaction has been committed → RECO finalizes the commit.
- Otherwise → it performs the rollback to ensure consistency.
- When completed, RECO deletes the outstanding transaction record and the system returns to a clean state.
- All this is done automatically, without intervention from the DBA.
Importance of RECO
The Recoverer Process is crucial for environments where databases interact across networks, for three reasons:
- Data consistency: ensures that transactions are either fully committed or fully rolled back, preventing data corruption.
- Automatic Recovery: Automatically resolves issues, reducing manual recovery efforts.
- Maintainability: Simplifies the management of distributed transactions in multi-database environments.
Recovery Writer Process (RVWR)
Role of the Recovery Writer Process
The Recovery Writer Process (RVWR) plays a vital role in Oracle Flashback Technology. This technology is one of Oracle’s most powerful features — it allows you to rewind the database to an earlier date without requiring restoration from backups.
Flashback features enabled by RVWR
| Feature | Description |
|---|---|
| Flashback Query | Allows you to view past data without restoring backups. |
| Flashback Table | Allows you to restore a specific table to an earlier date. |
| Flashback Database | Allows you to rollback the entire database to an earlier point in time. |
Without the Recovery Writer Process, none of these features would be possible.
RVWR Operation Flow
Example: a user accidentally executes a DELETE command on all of a department’s data.
Step 1 — Capture in Flashback Buffer
Before the DELETE command physically deletes the data, Oracle writes a before image of the affected data blocks to the SGA flashback buffer. The flashback buffer temporarily stores recent data changes in memory — meaning that the original data still exists in memory, even after deletion.
Step 2 — Read by RVWR
The RVWR continuously reads these before images from the flashback buffer. The timing of these reads depends on several factors such as transaction frequency and memory size.
Step 3 — Writing to the Flashback Log
The RVWR writes the before images to the flashback log stored in the fast recovery area. These logs allow Oracle to return to a previous state by having historical records of changes.
Checkpoints and archiving process
The Checkpoint Process
The Checkpoint Process forces all modified data in memory to be written to physical data files on disk. This ensures that the database is in a consistent state and can recover more efficiently after a crash or unexpected shutdown.
Checkpoint Triggers
A checkpoint can be triggered by:
- Redo log files become full (causing a log switch).
- The database is shutting down.
- A manual checkpoint is issued.
Checkpoint Flow
1. The process server manages the request
The data change is first recorded in the database buffer cache (in-memory) for performance reasons. This change is not immediately written to disk.
2. Triggering the checkpoint
Over time, Oracle triggers a checkpoint.
3. The Checkpoint Process instructs the Database Writer
The Checkpoint Process does not write data directly to disk. It instructs the Database Writer Process (DBWn) to handle this operation.
4. The Database Writer writes to disk
The DBWn reads dirty data blocks from the database buffer cache and writes them to the appropriate data files in the database area:
- SYSTEM (database objects)
- SYSAUX (auxiliary system data)
- User data
- Temporary data for sorts and large operations
- Information for rolling back uncommitted changes
5. Updating Control Files
While the DBWn is writing data, the Checkpoint Process is also updating the control files to record the checkpoint information. This metadata is crucial for Oracle to know the latest consistent state of the database.
6. Fast Recovery Area
Oracle can also write to the fast recovery area for backup and recovery operations.
Database Writer Process (DBWn)
Role of the Database Writer Process
The Database Writer Process (DBWn) is responsible for moving changed data from memory to disk. Instead of writing each small change directly to disk, Oracle optimizes performance by first holding changes in memory and then writing them to disk in bulk.
Multiple Database Writer Processes
Oracle may have multiple database writer processes depending on the workload. These processes (named DBW0, DBW1, DBW2, etc.) work in parallel to efficiently handle large volumes of data.
DBWn operation flow
Step 1 — User request and in-memory modification
User executes SQL commands (INSERT, UPDATE, DELETE). The server process handles the request. The change is recorded in the database buffer cache, a memory structure of the SGA. The updated data is now in memory but not yet written to disk.
Step 2 — Reading the Database Buffer Cache
The DBWn regularly reads data from the cache. It focuses on:
- Dirty buffers: data blocks modified but not yet written to disk.
- Least recently used buffers: Data that might need to be cleaned to make room for new data.
Step 3 — Write to disk
Once the DBWn identifies modified dirty data, it writes this data to the physical data files on disk. By writing in bulk, DBWn reduces disk I/O and improves performance.
Step 4 — Database Smart Flash Cache (optional)
In some high-performance environments, Oracle leverages the database smart flash cache. The DBWn can also write data to flash storage (SSD), which is faster than traditional disks.
DBWn write triggers
The DBWn does not write data immediately after each change. It writes data only:
- When the cache buffer is full.
- When new transactions require space.
- During checkpoints.
Archiver Process (ARCn)
Role of the Process Archiver
The Archiver Process is a critical process that ensures data recoverability. It is responsible for copying the filled redo log files to a secure storage location known as the fast recovery area, or to another specified archiving destination.
This process is essential when the database is operating in archive log mode, ensuring that any changes made to the database can be recovered in the event of a failure.
Oracle may have multiple archiver processes (ARCn). These processes work in parallel to efficiently manage large volumes of redo data.
ARCn operation flow
Step 1 — Transaction and redo log
The user is executing a query. The change is first recorded in the SGA redo log buffer. The Log Writer Process writes this redo data to the redo log files in the database area.
Step 2 — Log switch
Redo log files have a finite size. When a redo log file becomes full, the next file is used. When all logs are full, Oracle performs a log switch — which triggers ARCn.
Step 3 — Archiving
The ARCn is notified that a redo log file has been completed. It then copies the filled redo file to the archived redo files.
Step 4 — Release for reuse
Once the redo log is archived, it becomes available for reuse. This ensures continuous recording of database changes without interruption.
Why ARCn is critical
- Full database recovery: If a disk failure or corruption occurs, the database can be restored using the latest backups of the data files. Archived redo logs allow point-in-time recovery, allowing the database to be restored to a specific point in time before an error.
- Continuous Operations: Without archiving, redo logs would fill and the database would shut down until space is freed.
- Oracle Data Guard: archived redo logs are sent to standby databases to keep them replicated and synchronized with the primary database.
Archiving Monitoring and Management Commands
-- Vérifier le mode d'archivage
ARCHIVE LOG LIST;
-- Voir les archived logs
SELECT DEST_ID, STATUS, ARCHIVED, DELETED
FROM V$ARCHIVED_LOG;
-- Voir les destinations d'archivage
SELECT DEST_ID, STATUS, DESTINATION
FROM V$ARCHIVE_DEST;
Flashback Data Archiver Process (FBDA)
Role of the Flashback Data Archiver Process
The Flashback Data Archiver Process (FBDA) is responsible for capturing and storing historical changes to data. Its main role is to archive row versions of tables configured for flashback operations, thus allowing:
- To audit changes over time.
- To retrieve data from a specific point in the past.
- Track historical data without custom triggers or audit logic.
FBDA operation flow
Example: a user executes an UPDATE query.
Step 1 — Capture in Database Buffer Cache
The change is initially captured in the database buffer cache in the undo blocks. The original unmodified data before the change is stored in the undo segments of the data files.
Step 2 — FBDA Processing
Before the transaction is committed, the FBDA processes and reads data from the undo blocks in the database buffer cache. This allows the process to capture the original version of the data before it is permanently changed. The process ensures that each historical version of a row is securely saved for future retrieval.
Step 3 — Writing to the Flashback Data Archive
Once the FBDA has captured the original data, it writes this data to a dedicated flashback data archive residing in a specific tablespace. This flashback data archive stores all historical versions of data, allowing you to query or restore data as it existed at any time in the past.
Use with Flashback Queries
-- Interroger les données telles qu'elles existaient à un moment précis
SELECT * FROM employees
AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '1' HOUR);
Advantages of FBDA
- Compliance and audit: maintains historical versions of data without impacting application performance.
- Automation: Automates the management of historical data and eliminates the need for complex custom auditing mechanisms.
- Read Before COMMIT: Reads data before executing a COMMIT, thereby capturing the actual state of the data before modification.
Listener Processes and dynamic recording
The Listener Registration Process (LREG)
The Listener Registration Process is responsible for registering the Oracle Database Instance with the listener. The listener is a separate server-side process that handles incoming connection requests from client applications.
Dynamic recording flow
1. Starting the database
When Oracle Database starts, the LREG initializes automatically. This process dynamically notifies the listener of the status of the database instance, including the database name and the instances available for connection.
2. Processing a customer connection request
Example: A user attempts to connect to the database using SQL*Plus. The listener already knows the database instance because the LREG has already registered it. The listener forwards the connection request to the Oracle Instance. Without this record, the listener would not know where to route the connection and the client request would fail.
Dynamic Service Registration
One of the most powerful features of LREG is dynamic service registration. This means that Oracle services are automatically registered with the listener when the database starts. It is therefore not necessary to manually configure static entries in the listener.ora file. If new services or instances are added while running, the LREG will notify the listener in real time.
Why LREG is critical
| Reason | Description |
|---|---|
| Simplified configuration | Dynamic service registration removes the need for manual listener configuration, making database management more efficient. |
| High availability | If a database instance fails, the LREG automatically registers the new instance with the listener, ensuring continued availability. |
| Scalability | As new services or instances are added, LREG automatically registers them, adapting to changes in the environment without manual intervention. |
Process monitoring and diagnostics (Part 1)
The Process Monitor (PMON)
The Process Monitor is one of the critical background processes. If a user session or server process crashes during a request, the PMON quickly detects the failure:
- Cleans the resources (memory, logs) held by the faulty process.
- Release locks on data to avoid blocking other users.
- Notify the listener so that new connections can be established.
By doing this automatically, PMON ensures that the database remains stable and responsive, even when failures occur in the middle of query execution.
The Process Manager
When a query is executed, the Process Manager plays a key role in managing the different background processes and server processes:
| Role | Description |
|---|---|
| Dispatcher and shared server processes | The Process Manager manages these processes to efficiently manage multiple user connections, especially in multi-user environments. |
| Connection broker and pooled server processes | The Process Manager schedules and manages background tasks, such as scheduled jobs or batch processing, which can be triggered during the execution of a query. |
| Restartable background processes | If a background process fails during the execution of a query, the Process Manager automatically restarts this process to maintain system stability. |
The System Monitor Process (SMON)
When executing a query, SMON works quietly in the background. It recovers interrupted transactions left by failing sessions, cleaning up any incomplete activity that could have affected data integrity. It also performs periodic maintenance tasks to optimize storage and resource usage.
Process monitoring and diagnostics (Part 2) — AWR and ADR
Active Session History (ASH) and AWR
Oracle captures session activity every second. This data is stored in the active session history buffer, located in the SGA shared pool.
Performance data collection flow:
1. Capture in the Active Session History Buffer
The active session history buffer temporarily contains session activity details: wait events and resource usage. The Manageability Monitor Lite Process (MMNL) continually monitors and fills the active session history buffer with session data.
2. Flush to the Automatic Workload Repository (AWR)
When the active session history buffer is full, the MMNL flushes this data into the Automatic Workload Repository (AWR), specifically into the WRH$_ACTIVE_SESSION_HISTORY table located in the SYSAUX tablespace. This ensures that session performance data is preserved for historical analysis.
3. MMON Snapshots
The Manageability Monitor Process (MMON) collects and filters system performance statistics from the active session history buffer and other sources. Every 60 minutes, the MMON creates snapshots of system performance and stores this information in the AWR. These snapshots help DBAs analyze performance trends and troubleshoot issues over time.
4. Using historical data
Historical data captured by these two processes helps:
- Identify slow queries.
- Spot bottlenecks.
- Detect inefficient resource usage.
Automatic Diagnostic Repository (ADR)
The ADR is a centralized storage location for all diagnostic data, helping DBAs troubleshoot and resolve problems efficiently.
ADR content:
| File Type | Description |
|---|---|
| Foreground trace files | If a user session encounters errors (SQL errors, session hangs), the details are recorded here. |
| Dump files | Serious errors like data corruption or internal failures trigger the creation of dump files. |
| Health reports | Oracle Health Monitor automatically checks for potential data integrity and performance issues. |
| Incident files | If critical errors like ORA-600 or ORA-7445 occur, Oracle creates an incident in the ADR to facilitate diagnosis. |
4. Logical Storage Structures
Introduction to Logical Storage
Logical storage hierarchy
Oracle Database is designed to handle large volumes of data efficiently. To do this, it divides its storage into logical units that are easier to manage and optimize.
Tablespace (niveau le plus haut)
└── Segment (objets de la base de données)
└── Extent (ensembles de blocks alloués)
└── Block (plus petite unité, ~8 KB)
Tablespaces
At the top of the hierarchy are tablespaces. A tablespace is a logical container for all data. Each tablespace is associated with one or more physical data files on disk. Tablespaces allow you to group related data, apply storage policies, and control disk space allocation for different types of data.
Tablespaces predefined by Oracle:
| Tablespace | Role |
|---|---|
| SYSTEM | Stores metadata and administrative data. Contains the data dictionary. |
| SYSAUX | Auxiliary tablespace for Oracle components (AWR, Optimizer Statistics, etc.). |
| USERS | Default storage location for application data. |
| TEMP | Used for sorting and temporary operations. |
| UNDO | Supports transaction consistency. |
Segments
Inside a tablespace are segments, which represent the actual objects stored in the database:
- Segments for tables.
- Segments for indexes.
- Segments for undo data.
- Temporary segments.
Extents
Each segment type has a specific role. When a segment requires more space, Oracle allocates an extent. By allocating space in extents rather than individual blocks, Oracle ensures that related data remains physically close on disk, which improves performance. For example, when inserting rows into a table, the database automatically adds another extent from the tablespace.
Blocks
At the lowest level of the hierarchy are the blocks. These are the smallest storage unit in Oracle Database. The size of a block is typically around 8 KB, although it can be configured differently.
Specialized tablespaces (SYSTEM, SYSAUX)
The SYSTEM tablespace
The SYSTEM tablespace is automatically created when configuring a new database. It’s literally the brains of Oracle Database. Its main function is to host the data dictionary — a collection of metadata that the database uses to define and manage all objects in the system.
What the data dictionary contains:
- Tables, indexes, users.
- Privileges and structure of the tablespaces themselves.
Role in daily operations:
- When creating a new table: Oracle updates the data dictionary to save details (table name, columns, constraints).
- When a user executes a query: Oracle consults the data dictionary to validate that the table exists, check user permissions, and optimize the execution plan.
The SYSTEM tablespace also contains critical system objects such as PL/SQL packages and procedures used internally by Oracle. This is why Oracle strongly recommends keeping the SYSTEM tablespace dedicated to its default purpose and avoiding storing user data or application objects there. This could risk database stability and cause performance issues.
The SYSAUX tablespace
Introduced in Oracle 10g, the SYSAUX tablespace is the supporting pillar of the SYSTEM tablespace. Its role is to lighten the load on SYSTEM, allowing the SYSTEM tablespace to remain streamlined and focused on core operations.
Oracle components hosted in SYSAUX:
| Component | Description |
|---|---|
| Automatic Workload Repository (AWR) | Collects performance statistics and stores them for historical analysis. Crucial for identifying and resolving performance issues. |
| Optimizer Statistics | Stores statistics about tables and indexes used by Oracle’s query optimizer to generate efficient execution plans. |
| Streams | Used for replication and sharing of data between Oracle Databases. |
| Oracle Enterprise Manager (OEM) Repository | Stores configuration and monitoring data used by OEM to manage and monitor the database environment. |
| Segment Advisor | Stores information about segments that could be rebuilt to free up space. |
| SQL Tuning Advisor | Stores SQL performance analysis results and recommendations for query optimization. |
Monitoring SYSAUX components:
-- Identifier quels composants occupent le plus d'espace dans SYSAUX
SELECT OCCUPANT_NAME, SCHEMA_NAME,
SPACE_USAGE_KBYTES / 1024 AS "Space (MB)"
FROM V$SYSAUX_OCCUPANTS
ORDER BY SPACE_USAGE_KBYTES DESC;
UNDO Tablespace
What is the UNDO tablespace?
The UNDO tablespace is a special type of tablespace in Oracle Database that stores undo data — snapshots of the data before any changes are committed. This data is generated automatically every time a transaction modifies data.
Undo Data Functions
| Function | Description |
|---|---|
| Rollback | If a transaction fails or if a user explicitly rolls it back via a ROLLBACK, Oracle uses undo data to restore the assigned rows to their previous state. |
| Read Consistency | Undo data allows Oracle to provide consistent views of data to users, even when others modify that data. |
| Flashback features | This undo data is used by Oracle flashback features, such as Flashback Query. |
Undo Data storage mechanism
When a transaction modifies data (for example, updating a row in a table):
- Writing the new value: the database writes the new value into the database buffer cache to possibly be saved in the data file.
- Write old value: The database also writes the old value (before image) to the UNDO tablespace.
Undo data is stored in undo segments inside the UNDO tablespace. Each undo segment is essentially a container that tracks changes made by active transactions.
When the transaction is committed, undo data is no longer necessary for rollback. However, they may still be retained for read consistency or flashback operations until the undo retention period expires.
ACID and UNDO properties
Undo data is central to Oracle’s implementation of ACID properties:
| ACID Property | Role of UNDO |
|---|---|
| Atomicity | UNDO ensures that transactions are all or nothing. If a transaction is rolled back or fails midway, UNDO allows Oracle to restore the database to its original state. |
| Consistency | UNDO maintains database consistency during and after transactions. |
| Insulation | UNDO allows multiple users to interact with the database simultaneously. Even if a user updates certain rows, others can still query the row as it existed before the update. |
| Sustainability | Combined with redo logs, ensures committed transactions are persisted. |
Temporary UNDO
Oracle supports a feature called Temporary UNDO, which stores undo data for temporary tables in the temporary tablespace rather than the UNDO tablespace. This optimizes performance for scenarios involving heavy transactions on temporary tables.
Logical Storage Management Tools
This section presents useful SQL queries for managing logical storage in Oracle Database.
Monitor tablespace usage
-- Vue d'ensemble de chaque tablespace : taille totale, espace utilisé et libre
SELECT df.tablespace_name,
ROUND(SUM(df.bytes) / (1024*1024), 2) AS "Total (MB)",
ROUND(SUM(df.bytes) / (1024*1024) - NVL(SUM(fs.bytes) / (1024*1024), 0), 2) AS "Used (MB)",
ROUND(NVL(SUM(fs.bytes), 0) / (1024*1024), 2) AS "Free (MB)"
FROM DBA_DATA_FILES df
LEFT JOIN DBA_FREE_SPACE fs ON df.tablespace_name = fs.tablespace_name
GROUP BY df.tablespace_name
ORDER BY "Used (MB)" DESC;
Track segments in a tablespace
-- Identifier les segments dans un tablespace spécifique
SELECT segment_name, segment_type,
ROUND(bytes / (1024*1024), 2) AS "Size (MB)"
FROM DBA_SEGMENTS
WHERE tablespace_name = 'USERS'
ORDER BY bytes DESC;
This query is ideal for optimizing the tablespace layout.
Identify free blocks
-- Repérer la fragmentation ou les blocks inutilisés pouvant être récupérés
SELECT tablespace_name,
COUNT(*) AS "Free Extents",
ROUND(SUM(bytes) / (1024*1024), 2) AS "Free (MB)"
FROM DBA_FREE_SPACE
GROUP BY tablespace_name;
Monitor UNDO tablespace activity
-- Surveiller l'activité UNDO (undo blocks utilisés, nombre de transactions)
SELECT begin_time, end_time,
undoblks AS "Undo Blocks",
txncount AS "TXN Count"
FROM V$UNDOSTAT
ORDER BY begin_time DESC;
undoblks: space used for undo operations; txncount: total number of transactions during the interval. Useful for spotting trends or peaks in activity.
Quick summary of the UNDO tablespace
-- Taille, taille maximale et auto extension du tablespace UNDO
SELECT tablespace_name,
ROUND(SUM(bytes) / (1024*1024), 2) AS "Size (MB)",
autoextensible
FROM DBA_DATA_FILES
WHERE tablespace_name = 'UNDOTBS1'
GROUP BY tablespace_name, autoextensible;
Tip: it is always recommended to enable auto extension (
AUTOEXTEND ON) for UNDO tablespaces.
Historical view of UNDO activity
-- Vue historique de l'activité UNDO
SELECT begin_time, end_time,
maxquerylen AS "Longest Query (sec)",
undoblks AS "Undo Blocks Used"
FROM V$UNDOSTAT
ORDER BY begin_time;
Performance of undo in instances
-- Vue haut niveau de l'utilisation de l'espace UNDO dans les instances
SELECT inst_id, ssolderrcnt, nospaceerrcnt
FROM GV$UNDOSTAT
ORDER BY inst_id;
Status of undo segments
-- Statut des undo segments (actifs, inactifs, expirés)
SELECT status, COUNT(*) AS "Count",
ROUND(SUM(blocks) * 8192 / (1024*1024), 2) AS "Space (MB)"
FROM DBA_UNDO_EXTENTS
GROUP BY status;
5. Redo Logs and Control Files
Role and structure of Redo Logs
What is a Redo Log?
At its core, a redo log is a set of files in Oracle Database that record every change made to the database. It’s like a continuous log of all operations that modify data — whether it’s an INSERT, an UPDATE or a DELETE.
Crucial Point: Redo logs only capture changes to the data, not the data itself.
Example of what is recorded
For a table with two rows and two UPDATE transactions:
-- Transactions exécutées
UPDATE orders SET status = 'SHIPPED' WHERE order_id = 1001;
UPDATE orders SET status = 'DELIVERED' WHERE order_id = 1002;
The redo logs will record:
- The state before order status update (before image).
- The state after the update (after image).
Oracle thus allows these changes to be replayed or reversed if necessary.
The three critical roles of Redo Logs
| Role | Description |
|---|---|
| Crash recovery | If the database crashes, Oracle uses redo logs to return the database to a consistent state by replaying any changes that were not completely written to disk. |
| Data integrity | Redo logs ensure that even uncommitted changes are captured, so Oracle can rollback or roll forward transactions as needed. |
| Archiving support | Redo logs also enable features like point-in-time recovery. |
Operation of Redo Logs during normal operations
Write-ahead logging:
Before a transaction is committed, Oracle writes the change to the redo log buffer in memory. This is called write-ahead logging — it ensures that changes are recorded even before they are written to the database files.
The Log Writer (LGWR):
The Log Writer is the process responsible for flushing the redo log buffer to the redo log files on disk:
- When a transaction is committed.
- When the redo buffer reaches a certain threshold.
Structure of Redo Logs
Redo logs consist of groups. Oracle requires a minimum of two redo log groups to operate. Each group can have multiple members — copies of the same log on different disks for redundancy. Groups are used in a circular manner: when a group is full, Oracle moves to the next group via a log switch. Once all groups are full, Oracle recycles from the beginning, overwriting old redo logs (provided they have been archived if in archive log mode).
Importance of Control Files
What is a Control File?
We can think of control files as the blueprint or the roadmap of the database. They tell Oracle:
- Which data files and redo log files belong to the database.
- The current state of the database.
- Whether the database is in archive mode or not.
- And much more.
Control files contain all the critical information Oracle needs to open, operate, and recover the database.
Why Control Files are essential
Location of physical files:
Control files store the names and locations of all physical database files:
- Data files: contain the real data of the tables and indexes.
- Redo log files: critical for data recovery.
- Temp files: used for temporary operations like sorting.
Without control file, Oracle would not know which files belong to the database or where to find them.
Transaction integrity:
Control files maintain the current log sequence number and checkpoint information.
Database recovery support:
In the event of a failure, the control files are critical to restore the database. They tell Oracle which redo logs are needed for media recovery and provide the recovery sequence.
Contents of Control Files
| Information | Description |
|---|---|
| Database name and ID | Unique database identifier. |
| Paths to data files | Locations of all data files. |
| Redo log files and temp files | Locations and statuses. |
| Last checkpoint details | Helps Oracle determine recovery points. |
| Current and archived redo logs | Statuses and sequence numbers. |
| Backup metadata | Particularly those used with RMAN (Recovery Manager). |
| Archive log mode | If the database operates in archive log mode and the location of the archive logs. |
This metadata is constantly updated as the database runs.
Multiplexing of Control Files
Given their critical importance, Oracle strongly recommends multiplexing control files — that is, maintaining multiple copies on different disks. If one disk fails, Oracle can continue operating using the other copies.
Archived Redo Logs vs Online Redo Logs
General context
The two types of redo logs play distinct and critical roles in ensuring data recoverability in the event of failures — whether a crash, system failure, or full database recovery. Whenever data is modified, Oracle writes the changes to redo logs before committing them to the actual data files.
Online Redo Logs
Online redo logs record changes in real time as transactions are processed.
Features:
| Characteristic | Description |
|---|---|
| Circular operation | Work in a circular fashion — once a redo file is full, Oracle moves to the next redo log in the group. When all logs are full, it recycles and overwrites the oldest log. |
| Always active | These logs are in constant use while the database is running. |
| Crash recovery reviews | Used immediately to recover the database after a crash. |
| Limited retention | Since they are overwritten cyclically, online redo logs only retain the most recent changes. |
Archived Redo Logs
Archived redo logs are saved copies of online redo logs once they have been populated and are about to be overwritten.
Features and use cases:
| Use | Description |
|---|---|
| Point-in-time recovery | Allows you to restore the database to a specific point in time (for example, before a user accidentally deleted a table). |
| Media recovery | If a data file is lost or corrupted, archived redo logs reapply all changes made since the last backup. |
| Oracle Data Guard | Archived redo logs are sent to standby databases to keep them replicated and synchronized with the primary database. |
| Permanent backup | Unlike online redo logs which are overwritten, archived redo logs are saved to disk or other storage. |
Comparative summary
| Criterion | Online Redo Logs | Archived Redo Logs |
|---|---|---|
| Availability | Still active, in use | Saved when completed |
| Retention | Temporary (circular) | Permanent (until deleted) |
| Main role | Immediate crash recovery | Point-in-time recovery, Data Guard |
| Volume | Limited | May be bulky |
| Management | Automatic | Requires storage space |
Configuration of Redo Logs and multiplexing of Control Files
Multiplexing of Redo Logs
Multiplexing involves creating multiple copies of critical files (redo logs, control files) and storing these copies on separate physical devices. If one copy is lost or corrupted, the database can continue to function based on the other copies.
Steps to multiplex Redo Logs:
1. Identify current redo log groups
SELECT GROUP#, MEMBERS, STATUS
FROM V$LOG;
SELECT GROUP#, MEMBER
FROM V$LOGFILE;
2. Add a new member to an existing redo log group
ALTER DATABASE ADD LOGFILE MEMBER
'/u02/oradata/orcl/redo01b.log' TO GROUP 1;
ALTER DATABASE ADD LOGFILE MEMBER
'/u02/oradata/orcl/redo02b.log' TO GROUP 2;
ALTER DATABASE ADD LOGFILE MEMBER
'/u02/oradata/orcl/redo03b.log' TO GROUP 3;
Oracle then writes the same redo data to all members of the group. If one file fails, the others remain intact.
3. Check changes
SELECT GROUP#, MEMBER, STATUS
FROM V$LOGFILE
ORDER BY GROUP#;
Multiplexing of Control Files
Control files are even more critical because they store metadata about the database. It is strongly recommended to maintain multiple copies on different disks.
Steps to multiplex Control Files:
1. Check current locations of control files
SELECT NAME FROM V$CONTROLFILE;
-- Ou :
SHOW PARAMETER CONTROL_FILES;
2. Shut down the database properly
SHUTDOWN IMMEDIATE;
3. Copy the existing control file to the new location
# Linux/Unix
cp /u01/oradata/orcl/control01.ctl /u02/oradata/orcl/control02.ctl
4. Update the CONTROL_FILES parameter in the init file
-- Dans le fichier init.ora ou spfile
CONTROL_FILES = ('/u01/oradata/orcl/control01.ctl',
'/u02/oradata/orcl/control02.ctl')
5. Start database
STARTUP;
6. Check that the database uses both control files
SELECT NAME FROM V$CONTROLFILE;
By following these steps, multiple copies of the control files exist on different disks. If one disk fails, the database can continue to operate using the other control files.
Handling a missing or corrupt member redo log
-- Supprimer un membre défaillant
ALTER DATABASE DROP LOGFILE MEMBER '/u01/oradata/orcl/redo01b.log';
-- Ré-ajouter le membre
ALTER DATABASE ADD LOGFILE MEMBER
'/u01/oradata/orcl/redo01b.log' TO GROUP 1;
Monitoring and Troubleshooting Control Files
Analyze allocated space in Control Files
The following query reveals how space in the control files is allocated and used in different sections. It identifies:
- The record type (type of information stored in each section).
- The total number of allocated slots (
RECORDS_TOTAL). - The usage percentage (space used / total).
SELECT TYPE, RECORD_SIZE, RECORDS_TOTAL, RECORDS_USED,
ROUND(RECORDS_USED / RECORDS_TOTAL * 100, 2) AS "Utilization %"
FROM V$CONTROLFILE_RECORD_SECTION
ORDER BY "Utilization %" DESC;
Interpretation of results
Here is an analysis of typical sections of a control file:
| Section | Description | Usage example |
|---|---|---|
| DATABASE | Database information (name, creation date, unique ID). | Varies |
| CHECKPOINT PROGRESS | Follows the progress of checkpoints, critical during crash recovery. In the absence of recent heavy load, low use. | Low |
| REDO THREAD | Redo thread information. Example: 12.5% with 1 slot out of 8 used. | Varies |
| REDO LOG | Information about redo log files. Example: 18.75% with 3 slots out of 16 used. | Varies |
| DATAFILE | Follows the data files. Example: 1.17% with 12 slots out of 1024. Low usage indicates room for new data files. | Generally low |
| TABLESPACE | Tracks tablespaces and configurations. Example: 1.37% with 14 slots out of 1024. | Generally low |
| LOG HISTORY | Follows the life cycle of redo logs. Example: 6.51% with 19 slots out of 292. Useful for recovery. | Varies |
| ARCHIVED LOG | Archived logs registry for recovery and replication. Example: 35.71% with 10 slots out of 28. | Can get high |
Other monitoring requests
-- Surveiller les redo log groups et leur statut
SELECT GROUP#, SEQUENCE#, BYTES/1024/1024 AS "Size (MB)",
MEMBERS, STATUS
FROM V$LOG;
-- Taille des control files
SELECT BLOCK_SIZE * FILE_SIZE_BLKS / (1024*1024) AS "Control File Size (MB)"
FROM V$CONTROLFILE;
-- Informations sur les archive logs récents
SELECT SEQUENCE#, BLOCKS * BLOCK_SIZE / (1024*1024) AS "Size (MB)",
COMPLETION_TIME
FROM V$ARCHIVED_LOG
WHERE STANDBY_DEST = 'NO'
ORDER BY SEQUENCE# DESC;
Training: Understand Oracle Database 19c Architecture — Content based on official Oracle 19c documentation.
Search Terms
oracle · database · 19c · architecture · databases · sql · process · memory · redo · flow · undo · control · logs · pool · shared · storage · structures · processes · writer · role · tablespace · data · logical · monitor