Re: What is the best way to create Primary Key on a large table in Postgresql 9.5? - Mailing list pgsql-admin

From David G. Johnston
Subject Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?
Date
Msg-id CAKFQuwau_S_7+sR87uE_D51Ta4BB3ySHyXbWWoxFur+AsQe-qQ@mail.gmail.com
Whole thread Raw
In response to Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?  (Samed YILDIRIM <samed@reddoc.net>)
List pgsql-admin
On Thu, Aug 18, 2016 at 5:05 PM, Samed YILDIRIM <samed@reddoc.net> wrote:

Hi Ravi,

You can use CREATE INDEX with CONCURRENTLY keyword. It will not lock your table during the process.

​After which you would do:

ALTER TABLE tbl ADD PRIMARY KEY USING INDEX <index name from above>;
 

See the note on the linked page advising this exact procedure.

David J. 

pgsql-admin by date:

Previous
From: Keith
Date:
Subject: Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?
Next
From: Ravi Tammineni
Date:
Subject: Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?