Cookbook recipe

REINDEX TABLE Blocks All Reads and Writes During Rebuild

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation6 min

Scenario

Scenario A DBA notices that the orders table has a bloated index (dead tuple ratio over 40%) after a large bulk delete. To reclaim space and improve query performance, the DBA runs: REINDEX TABLE orders; This…

Investigation Path

Scenario

A DBA notices that the orders table has a bloated index (dead tuple ratio over 40%) after a large bulk delete. To reclaim space and improve query performance, the DBA runs:

REINDEX TABLE orders;

This acquires an AccessExclusiveLock on the table for the entire duration of the rebuild. The orders table has 50 million rows; the REINDEX takes approximately 20 minutes. During that window, every application query that touches orders — including simple SELECT statements — hangs waiting for the lock. The application becomes effectively unavailable.

The correct approach is REINDEX INDEX CONCURRENTLY (or REINDEX TABLE CONCURRENTLY, PG14+), which acquires only a ShareUpdateExclusiveLock and allows reads and writes to continue throughout the rebuild.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to Identify
  • Analysis Steps
  • Pitfalls
  • Resolution Approach
  • Mitigation Actions
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes