pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ravi Krishna <srkrishna@fastmail.com>
To: Denisa Cirstescu <Denisa.Cirstescu@tangoe.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL
Date: Tue, 22 Jan 2019 11:38:46 -0500
Message-ID: <038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com> (raw)
In-Reply-To: <MWHPR12MB1664CD85ECAB0420396FF210E6980@MWHPR12MB1664.namprd12.prod.outlook.com>
References: <MWHPR12MB1664CD85ECAB0420396FF210E6980@MWHPR12MB1664.namprd12.prod.outlook.com>


> 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.






view thread (3+ messages)  latest in thread

Message-ID: <038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com>
Permalink:  ../038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com/
Also on:    postgresql.org/message-id/038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com

 · 

reply

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: srkrishna@fastmail.com, Denisa.Cirstescu@tangoe.com
  Subject: Re: Decrease time needed to CREATE INDEX and FOREIGN KEY on new table column which has all values NULL
  In-Reply-To: <038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.com>
  References: <MWHPR12MB1664CD85ECAB0420396FF210E6980@MWHPR12MB1664.namprd12.prod.outlook.com> <038B7823-6C23-4606-9F1B-2B6BA097FDF9@fastmail.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