Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Ron
On 3/4/23 05:51, Peter J. Holzer wrote: On 2023-03-04 02:34:02 -0600, Ron wrote: On 3/4/23 02:03, Peter J. Holzer wrote: [snip] So your plan is to create a unique constraint (backed by a unique index) and then to drop the index and keep the constraint? That doesn't work. A unique constraint ca

Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Conner Bean
Ah, my apologies for missing that in the docs. I had previously noticed the CONCURRENTLY option on drop index, but I misread and incorrectly thought that unique indexes themselves could not be dropped concurrently, rather than that being true for only unique indexes backing constraints. Apologie

Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Peter J. Holzer
On 2023-03-04 02:34:02 -0600, Ron wrote: > On 3/4/23 02:03, Peter J. Holzer wrote: > [snip] > > So your plan is to create a unique constraint (backed by a unique > > index) and then to drop the index and keep the constraint? > > > > That doesn't work. A unique constraint can't exist without a (uni

Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Ron
On 3/4/23 02:03, Peter J. Holzer wrote: [snip] So your plan is to create a unique constraint (backed by a unique index) and then to drop the index and keep the constraint? That doesn't work. A unique constraint can't exist without a (unique) index. Think about it: With a unique constraint Postgr

Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Peter J. Holzer
On 2023-03-04 13:50:28 +1300, David Rowley wrote: > On Sat, 4 Mar 2023 at 10:55, Ron wrote: > > On 3/3/23 04:54, David Rowley wrote: > > If you have a look at > > https://www.postgresql.org/docs/15/sql-dropindex.html check out the > > CONCURRENTLY option. That option allows an index to be dropped

Re: Dropping behavior for unique CONSTRAINTs

2023-03-04 Thread Peter J. Holzer
On 2023-03-02 20:30:41 -, Conner Bean wrote: > 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

Re: Dropping behavior for unique CONSTRAINTs

2023-03-03 Thread David Rowley
On Sat, 4 Mar 2023 at 10:55, Ron wrote: > On 3/3/23 04:54, David Rowley wrote: > If you have a look at > https://www.postgresql.org/docs/15/sql-dropindex.html check out the > CONCURRENTLY option. That option allows an index to be dropped without > blocking concurrent reads and writes to the table.

Re: Dropping behavior for unique CONSTRAINTs

2023-03-03 Thread Ron
On 3/3/23 04:54, David Rowley wrote: On Fri, 3 Mar 2023 at 23:17, Conner Bean wrote: 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

Re: Dropping behavior for unique CONSTRAINTs

2023-03-03 Thread David Rowley
On Fri, 3 Mar 2023 at 23:17, Conner Bean wrote: 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 loc