When Indexes Hurt: Write Overhead, Bloat and Unused Indexes

Indexes are not free. Measure write amplification, find unused and duplicate indexes in MySQL and PostgreSQL, handle bloat and create indexes without locking...

Published November 27, 2026

After learning how much an index can speed up reads, the natural instinct is to add more. Past a point, indexes start making a database slower: inserts crawl, replicas lag, the buffer pool fills with index pages nobody reads, and storage costs climb. This article shows how to measure the cost and clean up indexes that are not pulling their weight.

The concept

Every index is a second copy of some columns that must be kept perfectly in sync. Inserting one row into a table with eight indexes means nine B-tree insertions, each potentially causing page splits, WAL or redo log writes, and replication traffic. Updates to indexed columns delete and reinsert entries. In PostgreSQL, updating any indexed column also prevents HOT (heap-only tuple) updates, which forces new entries in every index on the table.

Indexes also compete for memory. The buffer pool or shared buffers cache both table and index pages. Rarely used indexes still get loaded on writes and evict useful pages. And indexes bloat: deletes and updates leave dead space that B-trees reclaim only partially, so an index can grow to several times its ideal size.

Write throughput vs number of indexes

0 secondary indexes100% baseline2 indexes≈72%5 indexes≈48%10 indexes≈29%
Illustrative insert throughput relative to an unindexed table. Real numbers depend on key types and hardware.

Write amplification

INSERT 1 rowStorage enginetable + every indexclustered / heapwriteidx_emailB-tree insertidx_createdB-tree insertidx_statusB-tree insert
One logical write becomes many physical writes.

Finding unused indexes

Both databases track how often each index is used since statistics were last reset. Check over a period that includes month-end jobs and rare reports before dropping anything, and check replicas too, since queries may run only there.

-- PostgreSQL: never-scanned indexes, biggest first
SELECT relname AS table, indexrelname AS index, idx_scan,
       pg_size_pretty(pg_relation_size(indexrelid)) AS size
FROM pg_stat_user_indexes
JOIN pg_index USING (indexrelid)
WHERE idx_scan = 0 AND NOT indisunique
ORDER BY pg_relation_size(indexrelid) DESC;

-- MySQL 8 (sys schema)
SELECT * FROM sys.schema_unused_indexes;
SELECT * FROM sys.schema_redundant_indexes;

Common index problems

ProblemSymptomFix
Unused indexidx_scan = 0 for weeksMake invisible/drop after verifying
Redundant index(a) exists alongside (a, b)Drop the prefix index
Bloated indexSize far larger than expectedREINDEX CONCURRENTLY / OPTIMIZE TABLE
Index blocking HOT updatesHigh n_tup_upd but low n_tup_hot_updAvoid indexing frequently updated columns
Locking index buildsWrites stall during CREATE INDEXCONCURRENTLY / ALGORITHM=INPLACE, LOCK=NONE

Practical examples

Test before dropping: invisible indexes

The optimizer ignores an invisible index but it is still maintained, so you can switch it back instantly.

-- MySQL 8
ALTER TABLE orders ALTER INDEX idx_orders_status INVISIBLE;
-- watch performance for a few days, then
ALTER TABLE orders DROP INDEX idx_orders_status;

Build and rebuild without blocking writes

Online operations are essential on busy tables.

-- PostgreSQL
CREATE INDEX CONCURRENTLY idx_orders_customer ON orders (customer_id);
REINDEX INDEX CONCURRENTLY idx_orders_customer;
DROP INDEX CONCURRENTLY idx_orders_old;
-- MySQL InnoDB
ALTER TABLE orders ADD INDEX idx_orders_customer (customer_id), ALGORITHM=INPLACE, LOCK=NONE;

Check HOT update ratio in PostgreSQL

A low ratio on an update-heavy table suggests an index on a frequently changed column.

SELECT relname, n_tup_upd, n_tup_hot_upd,
       round(100.0 * n_tup_hot_upd / nullif(n_tup_upd, 0), 1) AS hot_pct
FROM pg_stat_user_tables ORDER BY n_tup_upd DESC LIMIT 10;

Common mistakes

  • Adding an index for every slow query report without checking whether an existing one could be extended.
  • Dropping an "unused" index that only month-end reports or a replica use.
  • Running CREATE INDEX without CONCURRENTLY on a large busy PostgreSQL table, blocking writes for minutes.
  • Forgetting that a failed CREATE INDEX CONCURRENTLY leaves an INVALID index behind that must be dropped.
  • Indexing columns like updated_at or counters that change on every write.

Key takeaways

  • Every index adds write cost, memory pressure and storage.
  • Use pg_stat_user_indexes or sys.schema_unused_indexes to find dead weight.
  • Make indexes invisible before dropping, and build them online.
  • Watch for bloat and avoid indexing columns that change constantly.

FAQ

How long should I wait before declaring an index unused?

At least one full business cycle (often a month) and across all replicas, since usage statistics are per server.

Does a unique index count as unused if never scanned?

Not necessarily. It may be enforcing a constraint on every insert. Keep unique indexes unless the constraint is no longer needed.

How do I measure index bloat?

In PostgreSQL use pgstattuple's pgstatindex (avg_leaf_density) or community bloat queries. In MySQL compare data_free and index sizes in information_schema.tables.

More Databases articles