public inbox for [email protected]  
help / color / mirror / Atom feed
From: Michał Kłeczek <[email protected]>
To: Marcelo Fernandes <[email protected]>
Cc: Adrian Klaver <[email protected]>
Cc: [email protected]
Subject: Re: Best Approach for Swapping a Table with its Copy
Date: Fri, 14 Feb 2025 07:01:55 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAM2F1VOOn1izCrtcrDx4YUtCY-H64Vj5yvN5H1Lhk8kCY+_W6Q@mail.gmail.com>
References: <CAM2F1VP9nn0F6fSjbmhJCNSjv-dbAJcAytZ2HkTkZ0dGYZvxrw@mail.gmail.com>
	<[email protected]>
	<CAM2F1VOOn1izCrtcrDx4YUtCY-H64Vj5yvN5H1Lhk8kCY+_W6Q@mail.gmail.com>



> On 12 Feb 2025, at 22:27, Marcelo Fernandes <[email protected]> wrote:
> 
> On Thu, Feb 13, 2025 at 10:02 AM Adrian Klaver
> 
> Also pulling in your question in the other reply:
> 
>> Why can't you just add the exclusion constraint to the original table?
> 
> With unique constraints, one can use a unique index to create the constraint
> concurrently.
> 
> With check constraints, one can create the constraint as invalid and then
> validate it while only requiring a share update exclusive lock.
> 
> But with exclusion constraints, neither of those techniques are available. In
> that sense, there is no way to create this type of constraint in a large table
> without copying the original table, adding the constraint, and performing a
> table swap.
> 
> This is done to avoid having to hold an exclusive lock for a long amount of
> time, thus creating application outages.
> 

Just a wild idea (not sure if anyone suggested it in this thread and not sure if it is doable):

Create index concurrently and then fiddle with the catalog tables to define the constraint using this index?

—
Michal







view thread (8+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Best Approach for Swapping a Table with its Copy
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox