Oracle DB Keywords
Oracle DB Keywords
1. Buffer
• Description: A buffer in Oracle DB refers to a memory area in the buffer cache that
stores data blocks read from disk. When a query requests data, Oracle first checks
the buffer cache before fetching data from disk.
• Example: If a table scan is performed, the data blocks are read into the buffer
cache for subsequent operations.
2. Cache
3. Parsing
• Description: Parsing is the process Oracle uses to translate a SQL statement into
an execution plan. It includes syntax checks, semantic checks, and the generation
of an execution plan.
• Example: When you execute SELECT * FROM employees, Oracle parses this statement
to check its syntax and generate a plan for execution.
4. Hard Parses
• Description: A hard parse occurs when Oracle needs to parse a SQL statement for
the first time or cannot reuse an existing execution plan. This involves significant
CPU work as Oracle must analyze and optimize the query.
• Example: A hard parse happens when you run a SQL query with different literal
values that Oracle treats as unique statements, such as SELECT * FROM employees
WHERE department_id = 10 and SELECT * FROM employees WHERE department_id = 20.
5. Soft Parses
• Description: A soft parse occurs when Oracle can reuse an existing execution plan
from the library cache without fully parsing the SQL statement. This is faster and
consumes fewer resources than a hard parse.
• Example: If a previously executed query is run again using bind variables, Oracle
performs a soft parse and reuses the cached plan.
7. Latch Contention
8. Waits
• Description: Waits refer to the time a session spends waiting for a resource to
become available. Oracle tracks wait times to help diagnose performance
bottlenecks.
• Example: If a query waits for data to be read from disk, it may show a db file sequential
read wait event.
9. Wait Events
• Description: Wait events are specific conditions that a session encounters while
waiting for a resource. These events help identify what the database is waiting on,
such as I/O operations, latches, or locks.
• Example: Common wait events include db file scattered read, log file sync, and library
cache lock.
10. Locks
• Description: Logical reads are operations where Oracle retrieves data from the
buffer cache without accessing disk. It refers to reading data that is already in
memory.
• Example: A query that reads a data block from the buffer cache incurs a logical
read, which is faster than a physical read.
12. Deadlocks
• Description: A deadlock occurs when two or more sessions block each other by
holding resources that the other session needs, creating a cycle where no session
can proceed.
• Example: Session 1 locks Table A and waits for Table B locked by Session 2, while
Session 2 holds Table B and waits for Table A. This creates a deadlock that Oracle
resolves by aborting one of the sessions.
• Description: The PGA is a memory region that contains data and control
information for a server process. It is used for operations such as sorting, hash
joins, and other session-specific tasks.
• Example: When a query requires sorting, the PGA allocates memory for that sort
operation. If insufficient, it spills to disk, causing slower performance.
• Description: The SGA is a shared memory area that holds data and control
information for an Oracle instance. It includes the buffer cache, shared pool, and
other memory structures.
• Example: The shared pool within the SGA contains parsed SQL statements, while
the buffer cache holds frequently accessed data blocks.
• Description: The redo log consists of files that record changes made to the
database, ensuring data can be recovered in case of a failure. Each transaction
writes redo entries to the redo log buffer, which is then flushed to disk.
• Example: A COMMIT operation triggers Oracle to write redo entries from the redo log
buffer to the redo log files, ensuring the changes are saved and can be replayed
during recovery.
• Description: The library cache is a part of the shared pool within the SGA that
stores parsed SQL statements, PL/SQL code, and execution plans. This allows
Oracle to reuse execution plans and reduce the need for hard parsing.
• Example: When a SQL statement is executed, Oracle checks the library cache to
see if a parsed version already exists. If found, it performs a soft parse; if not, it hard
parses the statement and stores it in the cache.
• Description: The shared pool is a component of the SGA that holds various memory
structures, including the library cache and the data dictionary cache. It plays a
crucial role in SQL parsing and execution.
• Example: The shared pool helps manage the parsed SQL statements and
metadata. If it’s too small, Oracle may encounter library cache contention, leading
to performance issues.
• Description: The data dictionary cache, also known as the row cache, is part of the
shared pool that stores metadata information about database objects (e.g., tables,
columns, users). This helps reduce the need to repeatedly access the physical data
dictionary.
• Example: When a query references a table, Oracle checks the data dictionary
cache for metadata to validate the query. If the cache doesn’t contain the required
information, it fetches it from disk, which can slow performance.
• Description: Control files are crucial database files that store information about
the database structure, including datafile locations, redo log locations, and other
metadata essential for database operation.
• Example: During instance startup, Oracle reads the control file to identify the
database structure and ensure it is in sync. If the control file is damaged or missing,
the database will not start.
20. Checkpoint
• Description: The latch free wait event indicates that a process is waiting for a latch
that is currently held by another process. This can be due to contention in
accessing shared resources.
• Example: High latch free wait events often occur when there are many concurrent
queries trying to access the same memory structure, such as the shared pool or
redo log buffer.
• Description: Row lock waits occur when a session tries to modify a row that is
locked by another session. This prevents data corruption and ensures data
consistency.
• Example: If Session 1 updates a row in the orders table but hasn't committed the
change, Session 2 trying to update the same row will experience a TX - row lock
contention wait event until Session 1 commits or rolls back the transaction.
• Description: The redo log buffer is a part of the SGA where redo entries are
temporarily stored before being written to the redo log files on disk. It ensures data
changes are logged and recoverable.
• Example: If the redo log buffer is undersized or heavily used, you may see log buffer
space wait events, indicating that processes are waiting for the buffer to flush before
they can write more redo entries.
• Description: The log file sync wait event occurs when a session waits for a commit to
complete. This wait event measures the time it takes for redo entries to be written
from the redo log buffer to the redo log files.
• Example: If you frequently see high log file sync waits, it indicates slow redo log
writes. This can be mitigated by placing redo logs on faster storage or optimizing the
redo log buffer size.
• Description: The LGWR process is responsible for writing redo log entries from the
redo log buffer to the redo log files on disk. It is crucial for ensuring that changes are
safely recorded and available for recovery.
• Example: The LGWR process writes to disk when a transaction commits, when the
redo log buffer reaches a certain threshold, or at specific intervals set by the
database.
• Description: Consistent gets are logical reads of data blocks in the buffer cache
that ensure a consistent view of data for a query, even while other sessions might
be modifying the data.
• Example: When a SELECT statement is executed, Oracle retrieves the relevant data
blocks from the buffer cache, performing consistent gets to provide a consistent
snapshot.
• Description: Direct path reads bypass the buffer cache and read data directly from
disk to the PGA. This method is often used for large, full table scans or direct read
operations like CREATE TABLE AS SELECT.
• Example: When a large SELECT query reads data too big to benefit from caching,
Oracle may choose direct path reads for efficiency, reflected as direct path read wait
events.
• Description: Direct path writes are used to write large volumes of data directly from
the PGA to disk, bypassing the buffer cache. This is common in bulk operations,
such as INSERT APPEND.
• Example: INSERT /*+ APPEND */ INTO large_table SELECT * FROM another_table will write data
directly to disk, avoiding cache overhead and speeding up large data loads.
• Description: Data Guard is an Oracle feature for disaster recovery and high
availability. It maintains standby databases as replicas of the primary database and
can switch roles in case of a failure.
• Description: ASM is Oracle’s file system and volume manager that simplifies
storage management by automatically distributing database files across all
available disk devices to optimize performance and reliability.
• Example: ASM can rebalance data across disks when a new disk is added or
removed, without impacting database performance, which is useful for scaling
storage dynamically.
• Description: The ORA-01555 error, known as the “snapshot too old” error, occurs
when a long-running query tries to access an older version of data that has been
overwritten in the undo tablespace due to insufficient UNDO_RETENTION.
• Example: To prevent this, ensure the UNDO_RETENTION parameter is set
appropriately for long-running transactions and monitor the size of the undo
tablespace using V$UNDOSTAT.
• Description: Materialized views are database objects that store the results of a
query physically and can be refreshed periodically to keep them up-to-date. They
are used to improve query performance by avoiding repeated complex joins or
aggregations.
• Example: A materialized view created for a SELECT query with REFRESH FAST enables
it to be updated incrementally whenever the base tables are updated, reducing the
load on the system during refreshes.
• Description: The temporary tablespace is used for operations like sorting, hash
joins, and large ORDER BY clauses that exceed the memory allocated in the PGA. It
stores intermediate results temporarily.
• Example: When a query with ORDER BY needs to sort more data than the PGA can
handle, it spills to the temporary tablespace. Monitoring V$TEMPSEG_USAGE can help
identify large temporary space usage.
• Description: The SCN is a unique number that Oracle assigns to each committed
transaction. It serves as a timestamp and helps maintain data consistency and
recovery points.
• Example: The SCN is used during recovery and flashback operations to identify the
exact point in time to which the database needs to be restored.
• Description: Oracle uses B-tree structures for indexes to ensure efficient searching
and retrieval. Each index entry points to a row in a table, allowing for faster data
access compared to a full table scan.
• Example: When a query uses a WHERE clause with an indexed column, Oracle can
traverse the B-tree to find the relevant rows without scanning the entire table.
47. Histograms
• Description: Bind variables are placeholders in SQL statements that are replaced
with actual values at runtime. They help reduce hard parsing and improve SQL plan
reuse.
10 | P a g e Santhosh Kumar J
• Example: Instead of writing SELECT * FROM employees WHERE department_id = 10 and
SELECT * FROM employees WHERE department_id = 20, using SELECT * FROM employees WHERE
department_id = :dept_id ensures the same execution plan is reused.
• Description: Oracle Data Pump is a utility for fast data and metadata
export/import. It allows for high-speed transfer of data between databases and
supports parallel execution to improve performance.
• Example: To export a schema, you can use expdp with options like DIRECTORY,
DUMPFILE, and SCHEMAS to specify the schema and output location. This is useful for
data migration or backup purposes.
• Description: SQL Plan Baselines are a feature that allows the database to maintain
and use known, good execution plans. This ensures stability in query performance
by preventing the optimizer from choosing suboptimal plans.
• Example: If a query has an execution plan that is efficient, Oracle can capture and
store that plan as a baseline. This plan will be reused in future executions, even if
new statistics or changes might otherwise lead the optimizer to choose a different
plan.
• Description: Adaptive execution plans are dynamic plans that can change during
the execution of a query based on the actual statistics collected at runtime. This
helps Oracle adjust the execution strategy to optimize performance.
• Example: If a nested loop join initially appears optimal but actual runtime data
shows a hash join would be better, Oracle can switch to the hash join during the
execution phase.
• Description: The Flash Recovery Area is a location on disk where Oracle stores
recovery-related files such as backups, archived redo logs, and flashback logs. It
simplifies recovery operations and automates space management for recovery
files.
• Example: Configuring the FRA using parameters like DB_RECOVERY_FILE_DEST and
DB_RECOVERY_FILE_DEST_SIZE ensures that backup files and redo logs are managed in
one location for quick access during recovery.
11 | P a g e Santhosh Kumar J
53. Row-Level Security (RLS)
• Description: Direct path load bypasses the buffer cache and loads data directly
into datafiles. This is used for faster data loads, as it reduces the overhead of writing
to the buffer cache.
• Example: The SQL*Loader tool can perform direct path loading using the DIRECT=TRUE
option, which is useful for bulk data loading operations.
• Description: The ARCH process (Archiver Process) is responsible for copying redo
log files to the archive location when the redo log is full or a log switch occurs. This
ensures that redo logs are preserved for recovery purposes.
• Example: In databases operating in ARCHIVELOG mode, the ARCH process is
essential for creating archived redo logs, which are used for point-in-time recovery
and Data Guard synchronization.
12 | P a g e Santhosh Kumar J
58. Automatic Segment Space Management (ASSM)
• Description: The Oracle Resource Manager helps manage CPU, I/O, and other
resources among database users and applications. It enables prioritization and
resource allocation, ensuring critical workloads receive adequate resources.
• Example: Resource plans can be created and managed using the
DBMS_RESOURCE_MANAGER package to limit the CPU usage of background and non-
critical sessions.
• Description: SQL Trace is a debugging tool that collects performance data for SQL
statements. TKPROF processes the output of SQL Trace and generates a human-
readable report detailing the execution of SQL statements.
• Example: Enable SQL Trace for a session with ALTER SESSION SET SQL_TRACE = TRUE,
then use TKPROF to analyze the trace file and identify slow queries and optimization
opportunities.
• Description: When Oracle operates in ARCHIVELOG mode, redo logs are archived
before being overwritten. This allows for complete recovery of the database to any
point in time, ensuring data protection against failures.
• Example: Switching to ARCHIVELOG mode with ALTER DATABASE ARCHIVELOG ensures
that all changes are logged, enabling recovery up to the last committed transaction.
13 | P a g e Santhosh Kumar J
63. Dynamic Performance Views (V$ Views)
• Description: The EXPLAIN PLAN statement displays the execution plan for a SQL
query. It shows the steps Oracle takes to execute a query, such as table scans,
index usage, and join methods.
• Example: Use EXPLAIN PLAN FOR SELECT * FROM employees; and view the plan with
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); to understand how the query is processed.
• Description: Oracle does not have clustered indexes like SQL Server, but it
supports index-organized tables (IOTs), where the data is stored in the order of the
index, providing faster access for specific queries.
• Example: Creating an index-organized table with CREATE TABLE employees (id NUMBER
PRIMARY KEY, name VARCHAR2(50)) ORGANIZATION INDEX; ensures that the data is
physically stored in the order of the id column.
• Description: Global Temporary Tables are database tables that hold data specific
to a session or transaction. Data in these tables is private to the session and is
deleted automatically at the end of the session or transaction.
• Example: Create a GTT using CREATE GLOBAL TEMPORARY TABLE temp_sales (sale_id
NUMBER, amount NUMBER) ON COMMIT DELETE ROWS;. Data inserted during a session is
visible only to that session and is removed upon commit or session end.
67. SQL*Loader
• Description: Index Organized Tables store data in a B-tree index structure, where
the table rows are stored in the order of the primary key. This structure provides fast
retrieval for primary key-based queries.
• Example: Creating an IOT with CREATE TABLE products (product_id NUMBER PRIMARY KEY,
name VARCHAR2(100)) ORGANIZATION INDEX; ensures that the product_id column is
indexed and the data is stored accordingly, improving access times for queries
based on product_id.
• Description: SQL Profiles are performance tuning tools that store auxiliary
information for the optimizer to use when generating execution plans. This helps the
optimizer choose better plans by providing additional context about data
distribution and execution statistics.
• Example: Use the SQL Tuning Advisor to create a SQL Profile that the optimizer can
use to improve the execution plan for a specific query without changing the SQL
code itself.
15 | P a g e Santhosh Kumar J
• Example: When creating a disk group with CREATE DISKGROUP dg_data NORMAL
REDUNDANCY DISK '/dev/sd1', '/dev/sd2';, ASM stores two copies of the data for
redundancy. This ensures that if one disk fails, the data remains accessible.
• Description: Bitmap indexes use bitmaps to represent data, making them suitable
for columns with a low cardinality (few distinct values). They are efficient for
complex WHERE clauses and multi-column filtering.
• Example: A bitmap index created on a status column with only a few distinct values
(e.g., 'Active', 'Inactive') can improve the performance of queries that filter on this
column, such as CREATE BITMAP INDEX idx_status ON employees(status);.
• Description: Check constraints are rules enforced by the database to ensure that
column values meet specific conditions. They maintain data integrity by restricting
the data that can be inserted or updated in a column.
• Example: A salary column can have a check constraint to ensure it is positive: ALTER
TABLE employees ADD CONSTRAINT chk_salary CHECK (salary > 0); . This prevents any entry
with a non-positive salary.
16 | P a g e Santhosh Kumar J
77. Redo Log Switch
• Description: A redo log switch occurs when Oracle fills a redo log file and begins
writing to the next available log file. Log switches help in the continuous recording of
transactions and facilitate checkpointing.
• Example: If the redo log group size is small and transaction volume is high, log
switches will occur frequently, potentially causing log file switch (checkpoint incomplete)
waits. This can be mitigated by increasing the size of the redo log files.
• Description: The CBO is Oracle's query optimizer that determines the most
efficient way to execute a SQL statement based on statistics and the cost of various
execution plans. It compares different query plans and chooses the one with the
lowest estimated cost.
• Example: The CBO might choose an index scan over a full table scan for a query like
SELECT * FROM orders WHERE order_id = 100; if the statistics show that using the index is
more efficient.
17 | P a g e Santhosh Kumar J
82. DBMS_JOB and DBMS_SCHEDULER
• Description: Redo Apply is used in physical standby databases to apply redo logs
and maintain data synchronization, while SQL Apply is used in logical standby
databases to apply SQL statements.
• Example: Redo Apply uses redo logs to keep a physical standby up-to-date (ALTER
DATABASE RECOVER MANAGED STANDBY DATABASE;), whereas SQL Apply applies changes
in a logical format, allowing for data transformations.
• Description: Table partitioning splits large tables into smaller, more manageable
pieces called partitions. This improves performance by allowing Oracle to scan only
relevant partitions rather than the entire table.
• Example: Range partitioning can be implemented with CREATE TABLE sales (sale_id
NUMBER, sale_date DATE) PARTITION BY RANGE (sale_date) (PARTITION p1 VALUES LESS THAN
(TO_DATE('2023-01-01', 'YYYY-MM-DD'))); to organize data by date ranges.
• Description: Sparse indexes include only certain rows in the index, typically those
that meet a specific condition. This can optimize queries that focus on a subset of
data.
• Example: A partial index on a status column might only include rows where status =
'Active', improving query performance for SELECT * FROM employees WHERE status =
'Active';.
• Description: Striped and Mirrored Extents (SAME) in Oracle ASM provide a balance
of striping data across disks for performance and mirroring it for redundancy.
• Example: By creating a disk group with NORMAL REDUNDANCY, ASM stripes data
across disks and mirrors extents, ensuring data redundancy while optimizing read
and write performance.
• Description: Scheduler chains in Oracle allow for the creation of complex job
sequences where jobs can run conditionally based on the success or failure of
other jobs.
• Example: Using DBMS_SCHEDULER, you can create a chain with job dependencies,
ensuring that data loading starts only after data extraction is complete and verified.
19 | P a g e Santhosh Kumar J
92. Flashback Versions Query
• Description: Cache Fusion is an Oracle RAC technology that keeps data consistent
across nodes by allowing nodes to share data directly from their memory instead of
reading from disk.
• Example: When a query in Node A needs a block modified by Node B, Cache Fusion
transfers the block directly over the cluster interconnect, ensuring high availability
and performance.
• Description: Consistent Gets are logical reads of data blocks as they appeared at
the start of a query. DB Block Gets are direct reads of data blocks as they are
currently stored, without ensuring read consistency.
• Example: A SELECT query that scans data will use consistent gets to show data as it
was when the query started. A SELECT FOR UPDATE might use DB Block Gets to access
the current state of data.
• Description: Oracle Restart is a feature that ensures that Oracle components (such
as databases, listeners, ASM) are automatically restarted in the correct order when
a server is restarted.
• Example: Oracle Restart can be configured using the srvctl utility to monitor and
automatically start the database and related components after a server reboot.
20 | P a g e Santhosh Kumar J
97. Private vs. Public Synonyms
• Description: Invisible indexes are not considered by the optimizer by default but
can be used for testing the impact of adding or removing an index without actually
dropping it.
• Example: Create an invisible index with CREATE INDEX inv_idx ON employees(last_name)
INVISIBLE; and test performance before deciding to make it visible using ALTER INDEX
inv_idx VISIBLE;.
21 | P a g e Santhosh Kumar J