Re: Disable unique constraint in Postgres - Mailing list pgsql-admin

From Mladen Gogala
Subject Re: Disable unique constraint in Postgres
Date
Msg-id 88df5cb3-913f-182e-22ed-cbdc62fdd7d6@gmail.com
Whole thread Raw
In response to Re: Disable unique constraint in Postgres  (Ron <ronljohnsonjr@gmail.com>)
Responses Re: Disable unique constraint in Postgres
List pgsql-admin
On 11/27/22 16:23, Ron wrote:

Being an "enterprise dba", IMNSHO "disable constraint" (and more specifically "disable index") is a great feature for maintaining tables.  For example, if you need to purge a lot of records into a table, disable all indices except the index supporting your WHERE CLAUSE, delete the data, and then re-enable the indices.  Bonus points if the REENABLE commands can be done in parallel.

Sure, you can dig around for all of the CREATE INDEX statements, but that leads to possible errors: "oops, forgot to recreate one of them", or "typo caused one to fail".  OTOH, DISABLE INDEX and REENABLE INDEX are idiot-proof, and can be automated.

--
Angular momentum makes the world go 'round.


You are aware that in Oracle "ALTER TABLE ENABLE CONSTRAINT" rebuilds the index used to enforce the constraint? You will not save any time by disabling and re-enabling constraints.

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com

pgsql-admin by date:

Previous
From: Ron
Date:
Subject: Re: Disable unique constraint in Postgres
Next
From: Ron
Date:
Subject: Re: Disable unique constraint in Postgres