From: Conner Bean <conner.bean@icloud.com>
To: pgsql-general@postgresql.org
Subject: Dropping behavior for unique CONSTRAINTs
Date: Thu, 02 Mar 2023 20:30:41 -0000
Message-ID: <3d7d49f0-7eef-4d6d-8dc3-1993ba2fc2cb@me.com> (raw)
Hi folks,I'm curious if there are any docs supporting the functionality behind dropping unique constraints. For context, I am interested in enforcing uniqueness on a column. This table is heavily used, and I plan on dropping the constraint in the future. I wanted to avoid using a unique index since dropping them requires an exclusive lock and cannot be done concurrently. My thought was to then use a unique constraint, since I've read unofficial docs[0] that say these can be dropped safely with no lock.However, since a unique index would be the backing index to the unique constraint, I'm curious how this would work in practice (or if it even does!). Specifically if my theory of: "I can use a unique constraint to avoid obtaining an exclusive lock on my table" actually works.Thanks for any and all information, it's greatly appreciated, and apologies if I missed any existing documentation.Best, CSB0: https://leopard.in.ua/2016/09/20/safe-and-unsafe-operations-postgresql#.ZAEFpezMJLR
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: conner.bean@icloud.com
Subject: Re: Dropping behavior for unique CONSTRAINTs
In-Reply-To: <3d7d49f0-7eef-4d6d-8dc3-1993ba2fc2cb@me.com>
References: <3d7d49f0-7eef-4d6d-8dc3-1993ba2fc2cb@me.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox