Re: Adding constraints faster

Поиск
Список
Период
Сортировка
От sud
Тема Re: Adding constraints faster
Дата
Msg-id CAD=mzVUjcXY2Ss02aOiNWFCs46902pPM8HbXBrPg0sa=M=osbA@mail.gmail.com
обсуждение исходный текст
Ответ на Adding constraints faster  (sud <suds1434@gmail.com>)
Список pgsql-general

On Wed, May 15, 2024 at 2:09 AM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Tue, May 14, 2024 at 3:59 PM sud <suds1434@gmail.com> wrote:
*****
ALTER TABLE ADD FOREIGN KEY ... NOT VALID.
ALTER TABLE ... VALIDATE CONSTRAINT;


This is what we did, back in the PG 12.x period.  VALIDATE CONSTRAINT was almost instantaneous.  (Supporting indices existed, though.) 


Thank you. Actually we do have a composite index on the child table columns which is referring to the parent table. And in the parent table those columns are the primary keys. So even then it's taking ~20minutes for each partition. 

So is there some other way to make it run faster 
or
 Can we run it concurrently 
or
Should we keep the existing constraints in "not valid" state only?

В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Using ALTER TABLE DETACH PARTITION CONCURRENTLY inside a procedure
Следующее
От: Kashif Zeeshan
Дата:
Сообщение: Re: pg_stat_io clarifications: background worker, writes and reads