On Tue, Aug 27, 2019 at 9:33 AM Simon Kissane <skissane@xxxxxxxxxxxx> wrote: > If I swap the order of the CREATE UNIQUE INDEX and the INSERT, so the index gets created first, the error doesn't happen. It also works removing the INITIALLY DEFERRED from the foreign key, since it seems you are creating tuples in the right order (at least in this simplified model). The index is not created because the foreign key is validated at the transaction commit. > > I don't understand why having a deferred FK to check should stop me from creating a unique index. I also don't understand why this worked in 9.6 but not anymore. I've tested against 12beta2, it would be nice to understand what changed in (I suspect) SET TRANSACTION. Luca