Cookbook recipe

CLUSTER TABLE Blocks Production: No Concurrent Option

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

Scenario

Scenario A DBA notices that range scans on the orders table by created_at are slow due to poor physical row locality — pages are fragmented across the heap after months of random inserts and updates. The…

Investigation Path

Scenario

A DBA notices that range scans on the orders table by created_at are slow due to poor physical row locality — pages are fragmented across the heap after months of random inserts and updates. The DBA runs:

CLUSTER orders USING orders_created_at_idx;

CLUSTER rewrites the entire table in the physical <a class="sev1-termlink" href="https://thesev1database.com/glossary/pathkeys/">sort order of the chosen index. It acquires an AccessExclusiveLock on orders for the full duration of the rewrite. With 80 million rows, the operation takes 15 minutes. Every application query against orders — reads and writes — hangs for the entire window. Unlike REINDEX, there is no CLUSTER CONCURRENTLY option in any PostgreSQL version.

The production-safe alternative is the pg_repack extension, which rewrites the table without holding a long AccessExclusiveLock.

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