Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL

From: Ravi Krishna <srkrishna(at)fastmail(dot)com>
To: Denisa Cirstescu <Denisa(dot)Cirstescu(at)tangoe(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL
Date: 2019-01-22 16:38:46
Message-ID: 038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> The table is huge and it takes a lot of time to add the INDEX and the FOREIGN KEY although all values are NULL.
> Considering that the new DepartmentId column is NULL for all rows at this point, is there a way to make the INDEX and FOREIGN KEY creation run faster?

In your script to create index add this:

set maintenance_work_mem = '1GB'
or any other figure you feel comfortable.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2019-01-22 16:47:37 Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL
Previous Message Denisa Cirstescu 2019-01-22 16:29:48 Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL