Oracle-Db Essentials Imp
Oracle-Db Essentials Imp
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
an
accessed data and objects to reduce disk I/O. The most common types are the
buffer cache, library cache, and result cache.
Irf
• Example: The buffer cache stores copies of data blocks from the database, while
the library cache holds parsed SQL statements and execution plans.
ed
3. Parsing
• Description: Parsing is the process Oracle uses to translate a SQL statement into
m
an execution plan. It includes syntax checks, semantic checks, and the generation
of an execution plan.
am
• Example: When you execute SELECT * FROM employees, Oracle parses this statement
to check its syntax and generate a plan for execution.
oh
4. Hard Parses
• Description: A hard parse occurs when Oracle needs to parse a SQL statement for
M
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.
1|Page
6. Latching
7. Latch Contention
an
when many SQL statements are parsed simultaneously, leading to library cache latch
waits.
Irf
8. Waits ed
• 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.
m
• Example: If a query waits for data to be read from disk, it may show a db file sequential
read wait event.
am
9. Wait Events
oh
• 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.
M
• Example: Common wait events include db file scattered read, log file sync, and library
cache lock.
10. Locks
2|Page
11. Logical Reads
• 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
an
Session 2 holds Table B and waits for Table A. This creates a deadlock that Oracle
resolves by aborting one of the sessions.
Irf
13. PGA (Program Global Area) ed
• 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.
m
• Example: When a query requires sorting, the PGA allocates memory for that sort
operation. If insufficient, it spills to disk, causing slower performance.
am
• 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.
M
• 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.
3|Page
16. Library Cache
• 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
an
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
Irf
metadata. If it’s too small, Oracle may encounter library cache contention, leading
to performance issues.
ed
18. Data Dictionary Cache
m
• 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,
am
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
oh
• 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.
an
• 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
Irf
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
ed
contention wait event until Session 1 commits or rolls back the transaction.
m
23. Deadlock Detection
am
•
produces a trace file with information about the sessions and SQL involved. This
helps diagnose and prevent future deadlocks.
M
• 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.
5|Page
25. Log File Sync Wait Event
• 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.
an
• 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.
Irf
27. Consistent Gets
ed
• 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
m
be modifying the data.
• Example: When a SELECT statement is executed, Oracle retrieves the relevant data
am
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
M
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.
6|Page
30. Sorts in PGA vs. Temporary Tablespace
an
maintains performance statistics for the database. It captures data such as wait
events, session activity, and SQL performance metrics at regular intervals.
• Example: AWR reports can be generated to identify performance bottlenecks and
Irf
understand resource utilization patterns using
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT and querying DBA_HIST_* views.
ed
32. Automatic Database Diagnostic Monitor (ADDM)
m
• Description: ADDM analyzes AWR data to automatically identify and diagnose
performance issues in the database. It provides recommendations to improve
am
• 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.
7|Page
• Example: A physical standby database continuously applies redo logs from the
primary database to stay synchronized, providing a backup that can be activated
during a failover.
an
• Description: ASM is Oracle’s file system and volume manager that simplifies
storage management by automatically distributing database files across all
Irf
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
ed
storage dynamically.
m
37. Block Corruption
am
•
reads and writes, and the DBMS_REPAIR package can be used to detect and fix block
corruption.
M
8|Page
39. Snapshot Too Old (ORA-01555)
• 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
an
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
Irf
load on the system during refreshes.
• 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.
oh
9|Page
• Example: If a datafile is lost or damaged, media recovery can restore it using the
last backup and apply redo logs to bring the database up to the last committed
transaction.
• 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.
an
• Description: Undo data stores the before-image of data changes made by
transactions, allowing changes to be rolled back and supporting read consistency.
The undo tablespace is where this data is stored.
Irf
• Example: When a ROLLBACK command is issued, Oracle uses undo data to revert
the affected rows to their previous state. The V$UNDOSTAT view provides statistics on
undo space usage and retention.
ed
46. Index B-Tree Structure
m
• Description: Oracle uses B-tree structures for indexes to ensure efficient searching
am
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.
oh
47. Histograms
M
• 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
• 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.
an
• 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
Irf
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
ed
new statistics or changes might otherwise lead the optimizer to choose a different
plan.
m
• 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.
oh
• 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
M
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
53. Row-Level Security (RLS)
an
• Example: If a SELECT query starts and a UPDATE occurs on the same data partway
through, Oracle uses undo data to provide the original state of the data as of the
start of the query.
Irf
55. Direct Path Load
ed
• 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
m
to the buffer cache.
• Example: The SQL*Loader tool can perform direct path loading using the DIRECT=TRUE
am
• 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
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.
an
• 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.
Irf
60. SQL Trace and TKPROF
ed
• 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-
m
readable report detailing the execution of SQL statements.
• Example: Enable SQL Trace for a session with ALTER SESSION SET SQL_TRACE = TRUE,
am
then use TKPROF to analyze the trace file and identify slow queries and optimization
opportunities.
users for security and compliance purposes. It helps track changes, data access,
and administrative actions.
• Example: Enabling standard auditing or Unified Auditing can log activities like
SELECT, INSERT, or changes to database objects, which are stored in DBA_AUDIT_TRAIL
for review.
• 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
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
an
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY); to understand how the query is processed.
Irf
65. Clustered Indexes
ed
• 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
m
index, providing faster access for specific queries.
• Example: Creating an index-organized table with CREATE TABLE employees (id NUMBER
am
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
M
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
an
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
Irf
indexed and the data is stored accordingly, improving access times for queries
based on product_id.
ed
70. SQL Profiles
m
• Description: SQL Profiles are performance tuning tools that store auxiliary
information for the optimizer to use when generating execution plans. This helps the
am
use to improve the execution plan for a specific query without changing the SQL
code itself.
M
15 | P a g e
• 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.
an
• Description: Bitmap indexes use bitmaps to represent data, making them suitable
for columns with a low cardinality (few distinct values). They are efficient for
Irf
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
ed
column, such as CREATE BITMAP INDEX idx_status ON employees(status);.
m
75. Check Constraints
am
• 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
oh
•
TABLE employees ADD CONSTRAINT chk_salary CHECK (salary > 0); . This prevents any entry
with a non-positive salary.
M
16 | P a g e
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.
an
• Example: OEM can be used to monitor session activity, generate AWR reports, and
run the SQL Tuning Advisor to identify performance issues and solutions.
Irf
79. Cost-Based Optimizer (CBO) ed
• 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
m
lowest estimated cost.
• Example: The CBO might choose an index scan over a full table scan for a query like
am
SELECT * FROM orders WHERE order_id = 100; if the statistics show that using the index is
more efficient.
allocates for database objects. Extent management can be either locally managed
(using bitmaps) or dictionary managed (using data dictionary tables).
• Example: A tablespace created with EXTENT MANAGEMENT LOCAL uses bitmaps to
track free and used extents, which reduces contention and improves space
allocation efficiency.
17 | P a g e
82. DBMS_JOB and DBMS_SCHEDULER
an
• Example: In a planned maintenance scenario, you can perform a switchover to a
standby database using ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY;. Failover
is used during a primary database failure to promote a standby database to primary.
Irf
84. Redo Apply and SQL Apply
ed
• 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
m
databases to apply SQL statements.
• Example: Redo Apply uses redo logs to keep a physical standby up-to-date (ALTER
am
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.
an
• 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';.
Irf
89. ASM Striped and Mirrored Extents (SAME)
ed
• Description: Striped and Mirrored Extents (SAME) in Oracle ASM provide a balance
of striping data across disks for performance and mirroring it for redundancy.
m
• Example: By creating a disk group with NORMAL REDUNDANCY, ASM stripes data
across disks and mirrors extents, ensuring data redundancy while optimizing read
am
• 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
M
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
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.
an
• 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
Irf
and performance.
• 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.
oh
• 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
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)
an
INVISIBLE; and test performance before deciding to make it visible using ALTER INDEX
inv_idx VISIBLE;.
Irf
99. Database Auditing Modes ed
• Description: Oracle provides different auditing modes such as standard auditing
and Unified Auditing. These modes help track database usage and changes for
compliance and security purposes.
m
• Example: Unified Auditing consolidates all audit records into one place and can be
managed with DBMS_AUDIT_MGMT. You can set up auditing to capture actions like
am
21 | P a g e