One of the common things DBAs come across while troubleshooting SQL performance issues is a Full Table Scan (FTS). Whenever we see `TABLE ACCESS FULL` in an execution plan, the first thought is often that the query is performing poorly and needs an index.
But is that always true? Not necessarily.
A Full Table Scan is not automatically a performance problem. In some situations, it is actually the most efficient way for Oracle to retrieve data. The challenge for a DBA is to understand why Oracle has chosen a Full Table Scan, whether that decision is appropriate, and how it affects overall database performance.
Let's look at Full Table Scans from a practical DBA perspective, including execution plans, performance considerations, troubleshooting, and situations where creating an index may not be the right solution.
What Is a Full Table Scan in Oracle?
A Full Table Scan occurs when Oracle reads all formatted data blocks of a table below its High Water Mark (HWM) and examines the rows to identify those that satisfy the query conditions.
SELECT *
FROM employees
WHERE department_id = 10;If Oracle chooses a Full Table Scan, it reads the table's blocks and checks the rows against the department_id = 10 condition. Even if only a few rows match, Oracle still scans the relevant table blocks.
One important point to understand is that Oracle does not necessarily read one block at a time. It can use multiblock reads, where multiple adjacent blocks are read in a single I/O operation. This makes Full Table Scans efficient for retrieving large volumes of data.
Oracle scans blocks below the HWM, not every allocated block in the segment. Unformatted space beyond the HWM is not part of the normal Full Table Scan.
How Does Oracle Perform a Full Table Scan?
When Oracle decides to perform a Full Table Scan, the process generally involves the following steps:1. Oracle identifies the table segment that needs to be accessed.2. It reads the formatted data blocks below the High Water Mark.3. It examines the rows within those blocks.4. It applies the query's filter conditions.5. It returns only the rows that satisfy the conditions.Oracle can use multiblock I/O to improve the efficiency of reading adjacent blocks.Depending on the execution method, Oracle may also perform direct path reads, particularly for certain large scans and parallel operations. Therefore, not every Full Table Scan necessarily follows the same buffer cache access pattern.From a DBA perspective, understanding this process is important because a Full Table Scan does not automatically mean that Oracle is reading data inefficiently.
Why Does Oracle Choose a Full Table Scan?
Oracle's Cost-Based Optimizer (CBO) evaluates available access paths and estimates their costs before selecting an execution plan. Even when an index exists, Oracle may decide that a Full Table Scan is more efficient.
Here are some common reasons.
No Suitable Index Exists
If there is no usable index for the query conditions, Oracle may choose a Full Table Scan.
SELECT *
FROM employees
WHERE department_id = 50;If no suitable index exists on `department_id`, Oracle may scan the entire table.
Query Returns a Large Number of Rows
Consider a table containing 10 million records. If a query retrieves 7 million rows, using an index may not be the most efficient approach.
Oracle might need to:
- Read the index blocks.
- Retrieve a large number of ROWIDs.
- Visit table blocks to fetch the actual rows.
In this situation, scanning the table directly may involve less overall work.
This is one of the main reasons Full Table Scans are common in reporting and analytical workloads.
Small Tables
For smaller tables, a Full Table Scan can be more efficient than using an index.
If the table occupies only a few blocks, Oracle can read those blocks directly rather than performing additional index traversal and table access operations.
Creating an index on every column of a small table is not necessarily beneficial.
Functions Applied to Indexed Columns
This is a common issue DBAs encounter during SQL performance troubleshooting.
Consider the following query:
SELECT *
FROM employees
WHERE UPPER(last_name) = 'KUMAR';Suppose a normal B-tree index exists on 'last_name'. Oracle may not be able to use that index efficiently for this predicate because the query applies the `UPPER()` function to the indexed column.
One possible solution is to create a function-based index:
CREATE INDEX idx_emp_upper_name
ON employees (UPPER(last_name));This allows Oracle to consider an index access path for the matching expression.
However, the decision should depend on the query workload and the overall impact of maintaining the additional index.
Stale or Inaccurate Optimizer Statistics
Optimizer statistics play an important role in execution plan selection. If table statistics, index statistics, or column statistics do not accurately represent the data, Oracle may estimate the number of matching rows incorrectly.
For example, Oracle may estimate that a query will return a small number of rows when it actually returns a large number, or vice versa.
This can influence whether the optimizer chooses an index access path or a Full Table Scan.
As a DBA, checking statistics should be part of the investigation before making changes to indexes or SQL statements.
Parallel Execution
Full Table Scans are also common in parallel query operations.
When parallel execution is used, Oracle can distribute scan work across multiple parallel execution servers.
This can improve performance for large data-processing operations, reporting queries, and data warehouse workloads.
However, parallel execution also consumes additional CPU, memory, and I/O resources. A Full Table Scan running in parallel is not automatically faster or better for the overall database.
Are Full Table Scans Always Bad?
The short answer is No.A Full Table Scan can be the most efficient access path depending on the query requirements and the amount of data being retrieved.For example, when a query retrieves most of the rows from a table, a Full Table Scan is often more efficient than using an index. Similarly, for smaller tables, scanning the available blocks directly can be faster than performing an index lookup. Full Table Scans are also common in reporting and analytical workloads where queries process millions of records.However, the situation can be different for OLTP workloads. If a query is expected to retrieve only one or a few records using a highly selective condition, but Oracle performs a Full Table Scan on a large table, it may indicate a performance issue that needs investigation. The same applies when a frequently executed query repeatedly scans a large table but returns very few rows.As DBAs, our objective should not be to eliminate every Full Table Scan but to understand whether the chosen access path is appropriate for the workload. For instance, a reporting query that reads 80% of a table may perform better with a Full Table Scan, whereas an OLTP query scanning millions of blocks to retrieve a single record deserves closer attention.The key is to understand why Oracle chooses a Full Table Scan rather than assuming it is always a performance problem.
How to Identify Full Table Scans in Oracle
As a DBA, one of the first steps in troubleshooting is identifying SQL statements that are performing Full Table Scans.
There are multiple ways to do this.
Check the Execution Plan
Use the following query to examine the execution plan of a SQL statement:
EXPLAIN PLAN FOR
SELECT *
FROM employees
WHERE department_id = 10;
SELECT *
FROM TABLE(DBMS_XPLAN.DISPLAY);Look for the following operation:
------------------------------------------------
| Id | Operation | Name |
------------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | TABLE ACCESS FULL | EMPLOYEES |
------------------------------------------------This indicates that Oracle has selected a Full Table Scan for the `EMPLOYEES` table.
EXPLAIN PLAN shows an estimated execution plan. It does not guarantee that the same plan was used during actual SQL execution.
For production troubleshooting, checking the actual cursor execution plan is generally more useful.
Check the Actual Execution Plan
Use `DBMS_XPLAN.DISPLAY_CURSOR` to examine the execution plan of an executed SQL statement.
SELECT *
FROM TABLE(
DBMS_XPLAN.DISPLAY_CURSOR(
'your_sql_id',
NULL,
'ALLSTATS LAST +PREDICATE'
)
);Replace `your_sql_id` with the SQL ID of the statement.
This can provide useful information such as:
- Actual execution statistics, when available.
- Estimated versus actual rows.
- Buffer usage.
- Predicate information.
- Execution plan operations.
For actual row-source statistics to be available, the statement must have collected runtime plan statistics, for example through the `GATHER_PLAN_STATISTICS` hint or an appropriate statistics setting.
If those statistics were not collected, `ALLSTATS LAST` may not show the actual row counts and I/O statistics you expect.
Find SQL Statements with High Physical Reads
A Full Table Scan can contribute to high physical I/O, particularly when a large table is repeatedly scanned and its blocks are not already available in memory.
The following query helps identify SQL statements with high physical reads from the shared SQL area:
SELECT
sql_id,
executions,
disk_reads,
buffer_gets,
rows_processed,
ROUND(
disk_reads / NULLIF(executions, 0),
2
) AS reads_per_execution
FROM v$sql
WHERE executions > 0
ORDER BY disk_reads DESC
FETCH FIRST 20 ROWS ONLY;This query helps identify SQL statements worth investigating.
However, remember that `DISK_READS` is a cumulative statistic for the cursor. It does not prove that all those reads were caused by Full Table Scans.
Always correlate the results with the execution plan.
How to Troubleshoot an Expensive Full Table Scan
When a Full Table Scan is identified in a production database, I would not immediately recommend creating an index.
Instead, I would follow a structured troubleshooting approach.
Identify the SQL ID
Start by identifying the SQL statement responsible for the high resource consumption.
SELECT
sql_id,
executions,
elapsed_time / 1000000 AS elapsed_time_sec,
cpu_time / 1000000 AS cpu_time_sec,
disk_reads,
buffer_gets,
rows_processed
FROM v$sql
WHERE sql_id = '&sql_id';Check the execution count and resource consumption.
A query that performs a Full Table Scan once may be perfectly acceptable. The same query executing thousands of times can become a performance concern.
Check the Execution Plan
SELECT *
FROM TABLE(
DBMS_XPLAN.DISPLAY_CURSOR(
'&sql_id',
NULL,
'ALLSTATS LAST +IOSTATS +PREDICATE'
)
);Look for:
- `TABLE ACCESS FULL`
- High buffer gets
- High physical reads
- Differences between estimated and actual rows
- Filter predicates
Pay particular attention to whether the query retrieves a small number of rows after scanning a large table.
Check Table Statistics
Check when the table statistics were last gathered and how many blocks Oracle estimates for the table.
SELECT
owner,
table_name,
num_rows,
blocks,
last_analyzed,
stale_stats
FROM dba_tab_statistics
WHERE owner = UPPER('&owner')
AND table_name = UPPER('&table_name');If statistics are stale or do not represent the current data distribution, investigate whether gathering fresh statistics is appropriate.
Do not gather statistics blindly on a production database. Consider the workload, maintenance window, existing statistics preferences, and execution plan impact.
Check Existing Indexes
Before creating a new index, check the indexes already available on the table.
SELECT
index_name,
index_type,
uniqueness,
status,
visibility
FROM dba_indexes
WHERE table_owner = UPPER('&owner')
AND table_name = UPPER('&table_name');To check indexed columns:
SELECT
index_name,
column_name,
column_position
FROM dba_ind_columns
WHERE table_owner = UPPER('&owner')
AND table_name = UPPER('&table_name')
ORDER BY index_name, column_position;Review whether the existing indexes support the query predicates and whether the column order is suitable for the query.
Check the SQL Predicates
Review the `WHERE` clause carefully.
Look for:
- Functions applied to indexed columns.
- Implicit data type conversions.
- Leading wildcard searches.
- Missing or inappropriate filter conditions.
- Predicates that return a large percentage of the table.
For example:
WHERE TO_CHAR(order_date, 'YYYY-MM-DD') = '2026-11-24'If `order_date` is indexed, applying `TO_CHAR` to the column may prevent the optimizer from using a normal index range scan for that expression.
A better approach is to use a date range:
WHERE order_date >= DATE '2026-11-24'
AND order_date < DATE '2026-11-25'This keeps the column unmodified and allows Oracle to consider an appropriate index access path.
The final plan still depends on selectivity, statistics, and the available access paths.
Review the Overall Database Impact
A Full Table Scan should also be evaluated from the database workload perspective.
Check:
- Is the query consuming excessive CPU?
- Are physical reads increasing?
- Is the query running frequently?
- Is it affecting other critical SQL statements?
- Is the scan contributing to high I/O latency?
- Is parallel execution consuming excessive resources?
A query can have an acceptable execution time individually but still create significant resource pressure when executed repeatedly.
Should DBAs Create an Index to Avoid Full Table Scans?
This is probably one of the most common questions during SQL performance tuning.The answer depends on how the application accesses the data.Indexes are useful when queries retrieve a small subset of rows. However, indexes also introduce additional overhead.Before creating an index, consider the following:
Selectivity of the column
If a column contains highly selective values, an index may help Oracle locate matching rows efficiently.
For example, an index on an employee ID is generally more useful for retrieving individual employee records than an index on a column containing only a few distinct status values.
DML overhead
Every additional index needs to be maintained when the underlying table data changes.
Frequent INSERT, UPDATE, and DELETE operations can increase index maintenance overhead.
Storage requirements
Indexes consume additional disk space. Creating unnecessary indexes can increase storage requirements and maintenance effort.
Query workload
An index that benefits one SQL statement may not necessarily improve overall application performance.
DBAs should evaluate the impact on the complete workload rather than optimizing one query in isolation.
Existing execution plan
Check whether Oracle is already using another efficient access path before introducing a new index.
The objective should be to improve overall SQL performance, not simply to remove `TABLE ACCESS FULL` from the execution plan.
Full Table Scans and Partitioned Tables
Partitioning is another important consideration, particularly in databases containing large volumes of historical or transactional data.
Consider an orders table containing several years of records, partitioned by `ORDER_DATE`. A query retrieving orders for a particular date range might look like this:
SELECT *
FROM orders
WHERE order_date >= DATE '2026-11-01'
AND order_date < DATE '2026-12-01';If the table is partitioned by `ORDER_DATE`, Oracle may use partition pruning to access only the relevant partitions.
The execution plan may show operations such as:
PARTITION RANGE SINGLE
TABLE ACCESS FULLThis is not necessarily a problem. Oracle is performing a Full Table Scan on the selected partition rather than scanning the entire table. For large partitioned tables, this can be an efficient approach, especially when the query retrieves a substantial portion of the selected partition.
As a DBA, always check partition pruning before concluding that a Full Table Scan is scanning the entire table.
DBA Best Practices for Handling Full Table Scans
When investigating Full Table Scans in a production environment, DBAs should focus on understanding the execution plan and the overall impact on database performance rather than immediately trying to eliminate the scan.
Start by reviewing the actual execution plan to understand how Oracle accesses the table. Monitor physical reads and buffer gets to identify SQL statements consuming excessive I/O and database resources. Make sure optimizer statistics are maintained appropriately, as outdated or inaccurate statistics can influence the optimizer's execution plan decisions.
It is also important to review SQL predicates for functions applied to indexed columns, implicit data type conversions, and other conditions that may affect index usage. Before creating a new index, evaluate the selectivity of the column and check whether existing indexes can support the query efficiently. Additionally, monitor frequently executed SQL statements, as a Full Table Scan that performs well once may become a performance concern when executed repeatedly.
For partitioned tables, check whether partition pruning is taking place. Oracle may perform a Full Table Scan on a specific partition rather than scanning the entire table, which can be an efficient access path. Similarly, review parallel execution settings to ensure that Full Table Scans are not consuming excessive CPU, memory, and I/O resources. Comparing estimated rows with actual rows is another useful step to identify cardinality estimation issues that may influence execution plan selection.
One more important recommendation is to avoid using optimizer hints such asFULLorINDEXas an immediate solution to performance issues.
For example:
SELECT /*+ INDEX(e IDX_EMP_DEPT) */
*
FROM employees e
WHERE department_id = 10;The INDEX hint influences Oracle to use the specified index, but forcing an access path without understanding the underlying issue can sometimes result in a worse execution plan.
As a DBA, use optimizer hints only when there is a clear technical justification, and always test their impact before implementing them in production.
The best approach is to understand the root cause, evaluate the available access paths, and make changes based on actual workload performance rather than assumptions.
As an Oracle DBA, seeing `TABLE ACCESS FULL` in an execution plan should not immediately raise a red flag.Full Table Scans are a normal part of Oracle database operations. They are often the most efficient choice for small tables, reporting queries, analytical workloads, and queries retrieving a large percentage of table data.
The real concern is when a Full Table Scan becomes expensive, executes frequently, consumes excessive I/O or CPU resources, and affects application response times.
Instead of blindly creating indexes or forcing execution plans, DBAs should understand the query requirements, review optimizer statistics, examine actual execution plans, and evaluate the overall workload.
The goal of SQL tuning is not to eliminate Full Table Scans. It is to ensure Oracle chooses the most efficient access path for the workload. That is the difference between simply identifying a Full Table Scan and troubleshooting it effectively as a DBA.
Comments
Post a Comment