Adding exclusion constraint in a big table

From: Marcelo Fernandes <marcefern7(at)gmail(dot)com>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Adding exclusion constraint in a big table
Date: 2024-10-24 06:43:53
Message-ID: CAM2F1VNeP1itvrO0rDrwJJU5Us8X4EE-jPQ2yYA7NjygeXq3ZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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?

Browse pgsql-performance by date

  From Date Subject
Next Message Laurenz Albe 2024-10-24 08:29:02 Re: proposal: schema variables
Previous Message Laurenz Albe 2024-10-23 04:11:08 Re: proposal: schema variables