Common Indexing Mistakes in Oracle Database: A DBA's Perspective

 

Indexes play an important role in Oracle Database performance. When a query takes longer than expected, one of the first things we usually check is whether the query is using the right index. But creating an index is not always the solution. I have seen situations where adding more indexes actually creates additional overhead, especially on tables that handle frequent INSERT, UPDATE, and DELETE operations. 

As the application grows, indexing requirements also change. An index that was useful a few years ago may no longer be needed, while some existing indexes may not be designed for the current workload. 
 
From a DBA perspective, the challenge is to identify which indexes are helping performance and which ones are adding unnecessary overhead. 
 
Let's look at some common indexing mistakes in Oracle Database.

Creating Too Many Indexes 

When a query performs poorly, creating an index can seem like the easiest solution. However, doing this for every performance issue can create problems over time. 
 
Consider a transaction table with several indexes created to support different application queries. SELECT statements may benefit from these indexes, but every relevant INSERT, UPDATE, or DELETE operation also requires Oracle to maintain them. On a busy OLTP database, this additional work can affect transaction performance and increase I/O activity. 
 
Before creating a new index, check whether an existing index can support the query. Also, look at how frequently the query runs and whether the proposed index is likely to make a meaningful difference.

Choosing the Wrong Column Order

Column order is important when creating a composite index in Oracle.

For example 

CREATE INDEX idx_orders_status_date
ON orders (status, order_date);
This index can help queries that filter by `status`, or by both `status` and `order_date`. However, a query that filters only by `order_date` may not benefit from this index as expected because `order_date` is not the leading column. 
 
This is a common mistake when designing indexes for tables used by multiple application queries. 
 
Before deciding the column order, review the actual SQL statements, their filter conditions, and the execution plans. The best order depends on the workload, not just on which column has the highest selectivity.

 Indexing Columns Without Checking Their Selectivity

Not every column is a good candidate for an index. 
 
For example, consider a large employee table with a `GENDER` column containing only a few distinct values. An index on this column may not help much if the query returns a large percentage of the table.

SELECT *
FROM employees
WHERE gender = 'F';
In this situation, Oracle may choose a full table scan instead of using the index. Reading the table directly can be more efficient than accessing a large number of rows through an index. 
 
However, low-cardinality columns are not always unsuitable for indexing. The decision depends on the data distribution, query conditions, and workload. 
 
As a DBA, check how many rows the query returns and review the execution plan before deciding whether an index is useful.

Ignoring Functions in WHERE Clauses

Sometimes an index already exists, but the query does not use it as expected because a function is applied to the indexed column. 
 
For example, suppose an index exists on `customer_email`.

CREATE INDEX idx_customer_email
ON customers (customer_email);
Now consider this query: 

SELECT customer_id, customer_email
FROM customers
WHERE UPPER(customer_email) = 'USER@EXAMPLE.COM';
The query applies `UPPER()` to the column. A normal index on `customer_email` may not provide the expected access path for this expression. 
 
One possible solution is a function-based index:

CREATE INDEX idx_customer_email_upper
ON customers (UPPER(customer_email));
Oracle can consider this index when the query uses the matching expression. 
 
When investigating this type of issue, check whether the SQL can be simplified or whether a function-based index would be appropriate for frequently executed queries.

 Keeping Redundant Indexes

Over time, tables can accumulate indexes that cover similar columns. This often happens when different teams create indexes to resolve individual performance issues.

For example:

CREATE INDEX idx_orders_customer
ON orders (customer_id);

CREATE INDEX idx_orders_customer_date
ON orders (customer_id, order_date);
At first glance, the first index may appear unnecessary because the second index also starts with `customer_id`. 
 
However, the two indexes do not necessarily serve the same purpose. The smaller index may be more efficient for certain queries. 
 
Before removing an index, check its usage, size, execution plans, and contribution to important SQL statements. Similar column definitions alone are not enough to decide whether an index is redundant.

Dropping Unused Indexes Too Quickly 

Unused indexes are another area where DBAs need to be careful. 
 
An index may not be used during normal business hours but could support a monthly report, a batch job, or an important reconciliation process. Oracle provides index usage monitoring features, but the monitoring period should cover the application's normal business cycle. 
 
For example, an index monitored for only two days may appear unused even though it supports a job that runs at the end of each month. Before dropping an index, review usage information, scheduled jobs, SQL execution plans, and constraint dependencies. Where appropriate, making an index invisible and testing the impact can help assess whether it is still required. 
 
The important point is not to remove an index simply because it appears unused in a short monitoring window.

Rebuilding Indexes Without a Clear Reason 

Index rebuilding is a common maintenance activity, but it should not be the first response to every performance issue. 
 
Sometimes a query becomes slow because of stale statistics, changes in data distribution, or a different execution plan. Rebuilding the index may not address the actual problem. Rebuilding can also consume significant I/O and generate redo, depending on the operation and configuration. 
 
Before rebuilding an index, check its execution plans, statistics, segment usage, and the specific problem you are trying to resolve. If the issue is related to optimizer statistics, gathering appropriate statistics may be more useful than rebuilding the index. 
 
A rebuild should have a clear technical justification rather than being performed simply because an index is old.

Ignoring the Impact on DML Operations 

Indexes are usually discussed in the context of SELECT performance, but their effect on DML operations is equally important. 
 
Consider a table that receives thousands of transactions every minute. If the table has many indexes, Oracle must maintain the relevant index entries as the data changes. This additional work can increase transaction overhead, particularly when indexed columns are frequently updated. 
For this reason, an index that improves a rarely executed report may not always be worth the additional cost on a heavily used transaction table. 
 
When reviewing indexes, consider both sides: how much they improve query performance and how much overhead they introduce during data changes.

Not Checking the Execution Plan After Creating an Index 

Creating an index does not guarantee that Oracle will use it. 
 
The optimizer evaluates available access paths and estimates their costs based on statistics, data distribution, and other factors. After creating an index, check the execution plan to see whether Oracle is using it and whether the query actually performs better. 
 
For a query whose runtime statistics have been collected, you can start with: 

SELECT *
FROM TABLE(
    DBMS_XPLAN.DISPLAY_CURSOR(
        NULL,
        NULL,
        'ALLSTATS LAST'
    )
);
This displays the execution plan for the last cursor, along with available runtime statistics. The relevant execution must have collected row-source statistics for those details to be available. 
 
Compare estimated and actual row counts where possible. If Oracle chooses an unexpected access path, investigate the underlying reason rather than assuming that another index is required.

What Should DBAs Check Before Changing an Index? 

 Before creating or dropping an index in a production database, I would recommend checking a few things:

- Review the SQL statements that use the table.

- Check existing indexes for overlap.
- Validate the column order of composite indexes.
- Examine execution plans and optimizer statistics.
- Review index usage over a representative period.
- Consider the impact on INSERT, UPDATE, and DELETE operations.
- Check the index size and maintenance overhead.
- Test the proposed change before implementing it in production.

These checks help avoid situations where a change improves one query but creates performance problems elsewhere.

Indexing problems are not always obvious. Sometimes a missing index is the issue, but in other cases, the database may already have too many indexes or an index that does not match the way the application accesses its data.

For DBAs, the important thing is to understand the workload before making changes. Reviewing SQL statements, execution plans, index usage, and DML activity provides a much better starting point than creating or rebuilding indexes based on assumptions.

The goal is not to have more indexes. It is to have the right indexes for the workload, without adding unnecessary overhead to the database.

Comments