Physical Design   «Prev  Next»

Lesson 4Downside to indexing
ObjectiveDescribe the trade-offs that occur by creating Indexes

Disadvantages of Creating Indexes on Column Fields of a Table

Indexes in databases are used to improve query performance by enabling faster data retrieval. However, there are several potential disadvantages to creating indexes on column fields of a table, including increased storage requirements, reduced write performance, and additional maintenance overhead. This document explores these disadvantages and provides guidance on when to consider using indexes judiciously.
Indexes play a crucial role in optimizing database performance by facilitating faster data retrieval. They can significantly improve query execution times, especially for large tables. However, creating indexes on column fields of a table is not without its drawbacks. This document outlines the key disadvantages of creating indexes and provides recommendations for using them appropriately.
  1. Increased Storage Requirements: One of the primary disadvantages of creating indexes is the additional storage space they require. Each index occupies storage space, which can become significant when multiple indexes are created on a table. This increased storage requirement can lead to:
    • Higher Storage Costs: The need for additional storage capacity can increase infrastructure costs, especially in large-scale or cloud-based environments.
    • Reduced Cache Efficiency: The larger storage footprint of indexes may reduce cache efficiency, as indexed data may compete with table data for available cache resources, potentially leading to performance degradation.
  2. Reduced Write Performance: Creating indexes on column fields can negatively impact write performance in a database. The following factors contribute to this performance reduction:
    • Index Updates: Whenever a row is inserted, updated, or deleted, the associated indexes must also be updated. This additional work can slow down write operations, especially when multiple indexes are involved.
    • Transactional Overhead: In transactional databases, maintaining index consistency can introduce additional overhead, as index updates must be coordinated with row changes, potentially increasing the complexity and duration of transactions.
  3. Additional Maintenance Overhead: Indexes require regular maintenance to ensure optimal performance. This maintenance overhead can create several challenges:
    • Index Fragmentation: Over time, index fragmentation can occur as data is inserted, updated, or deleted. This fragmentation can lead to decreased query performance and increased storage usage. Regular index maintenance is required to mitigate fragmentation.
    • Complexity in Tuning: With multiple indexes on a table, database administrators may face increased complexity when tuning and optimizing database performance, as they must carefully consider the interplay between indexes and queries.
    • Impact on Backup and Recovery: The presence of indexes can increase the time required for backup and recovery operations, as indexes must be backed up and restored along with the table data.

While indexes can significantly improve query performance in databases, there are several disadvantages to creating indexes on column fields of a table, including increased storage requirements, reduced write performance, and additional maintenance overhead. Database administrators and developers should carefully consider these drawbacks when designing database schemas and implementing indexing strategies. By using indexes judiciously and maintaining them properly, the negative impacts can be minimized, allowing for a balanced approach to database performance optimization.

Indexing a field allows an RDBMS to efficiently search for values in that field, though updating an index every time a new record is added to a table takes time. It is almost never correct to index every field in a table.
For instance, consider the following Order table:
CD table with columns 1)OrderNo 2) OrderDate 3) CDNo 4) OrderCost 5) Received
CD table with columns 1)OrderNo 2) OrderDate 3) CDNo 4) OrderCost 5) Received

While it would definitely make sense to create an index for the CDNo and OrderNo fields, indexing the OrderCost field would be a waste of time unless you needed to find out how many items Stories on CD purchased at each price point.

Choosing which indexes to create

Indexing a field results in faster searches and joins. But it also involves the following trade-offs:
  1. Increased disk space usage (not a concern today, though it was in the past).
  2. Slower insertions, deletions, and updates (the index must be updated every time one of these operations occurs).

Every RDBMS will automatically index a table's primary key field(s). Beyond that, you will generally get the best results from indexes if you create an index for every foreign key field, though if you use a non-foreign key field in a lot of searches and joins, you should check to see how indexing the field affects overall performance. As always, listen to your users: they'll tell you if the increase in data access speed is worth the decrease in update speed.
The next lesson introduces clustering.

Disadvantages of Indexing - Quiz

Before you move to the next lesson, click the Quiz link below to reinforce your understanding of indexing.
Disadvantages of Indexing - Quiz

SEMrush Software