Why my index is not being used

Back to list2026-07-23
You

The index exists but EXPLAIN shows a sequential scan.

ChatGPT

Usually one of three things: the query returns a large fraction of the table so the scan really is cheaper, the types do not match so the index is not applicable, or statistics are stale. ANALYZE the table first, then compare with SET enable_seqscan = off to see what the planner thinks the index would cost.

You

Users see their own edits disappear after saving. Replica lag?

ChatGPT

Almost certainly. Route reads that follow a write by the same user to the primary for a short window, or track the write LSN in the session and wait for the replica to reach it. The general fix is read-your-writes consistency, not lower lag.

You

I deleted 12M rows and the index is still the same size. Why?

ChatGPT

Deleting rows marks them dead but leaves index entries until vacuum reclaims the pages, and even then the pages stay allocated to that index. REINDEX INDEX CONCURRENTLY is what actually returns the space.