Diagnostic Queries
Symptoms
A statement referenced an index that does not exist. PostgreSQL raises SQLSTATE 42704 (undefined_object).
- The named index isn’t defined.
- Common in
DROP INDEX/ALTER INDEX/REINDEX. - Index names live in a schema like tables.
What the server log shows
ERROR: index "idx_orders_customer" does not exist
Why PostgreSQL raises this — what the manual says
the DROP INDEX reference (Description):
“A normal DROP INDEX acquires an ACCESS EXCLUSIVE lock on the table, blocking other accesses until the index drop can be completed.”
Indexes are named schema objects. Referencing a name that doesn’t exist (typo, already dropped, or wrong schema/search_path) cannot be resolved, so PostgreSQL reports 42704.
Common causes
- A typo or wrong case in the index name.
- The index was already dropped or never created.
- It lives in a schema not on the search_path.
How to fix it
- List indexes:
\dior querypg_indexes. - Use the exact (optionally schema-qualified) index name.
- Use
DROP INDEX IF EXISTSfor idempotency.
Related & next steps
Reference: PostgreSQL 18 — DROP INDEX.
Thanks — noted. This helps keep the database accurate.