Menu

1 / 3

CREATE INDEX CONCURRENTLY Failed. The INVALID Index It Left Can Still Tax Every Write

DEV Community: postgres·Gabriel Anhaia·11 days ago
#7vyyUPzj
#devtopostgresql#devto#dev#index#concurrently
Reading 0:00
15s threshold

Book: Database Playbook

Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

You ask your coding agent for a unique index on users.email . It writes CREATE UNIQUE INDEX CONCURRENTLY , which is the right call on a live table. The deploy fails. The agent reruns the migration, gets told the index already exists, adds IF NOT EXISTS , and CI goes green. Weeks later someone runs \d users and sees the word INVALID at the end of the index line.

None of this is a bug. The Postgres CREATE INDEX docs say that if a concurrent build hits "a deadlock or a uniqueness violation in a unique index", the command fails "but leave[s] behind an 'invalid' index. This index will be ignored for querying purposes because it might be incomplete; however it will still consume update overhead."

Queries get nothing from it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.