Thread: Adding exclusion constraint in a big table

Adding exclusion constraint in a big table

From
Marcelo Fernandes
Date:
Hi folks,

I need to add an exclusion constraint in a large table.

However, I'm worried about the length of time the table will be
blocked for reads and writes while the constraint is being
created.

With other operations, like adding unique indexes, I can create the
index first, concurrently, and then use that existing index to create
the constraint in place. This approach works well for large tables.

But this doesn't look like something I can do with exclusion
constraints, as I can't perform an ALTER TABLE ... USING INDEX ...

It also does not seem like I can add the constraint with a NOT VALID
condition either.

Do you folks have any recommendations for this situation?