Postgresql – Disappearing index

postgresql

We are running postgresql on a single instance on AWS RDS, currently on version 11.5
when creating the following index:

CREATE INDEX foo_idx
    ON public.foo_table USING gin
    (foo_col COLLATE pg_catalog."default" gin_trgm_ops)
    TABLESPACE pg_default;

it is created and queries utilizing it run fine, but after a number of them the index just disappears. recreating it works fine but it disappears again.

There is noting in the error logs, and we are not sure how to troubleshoot.

Best Answer

Thanks to Laurenz Albe:

Set log_statement = 'ddl' in postgresql.conf to log DDL statements. Also, verify that you didn't create the index in a transaction that got rolled back later.

Logging DDL statements surfaced the cause of the drop.