Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Samed YILDIRIM <samed(at)reddoc(dot)net>
Cc: Ravi Tammineni <rtammineni(at)partner(dot)aligntech(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?
Date: 2016-08-18 21:16:54
Message-ID: CAKFQuwau_S_7+sR87uE_D51Ta4BB3ySHyXbWWoxFur+AsQe-qQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, Aug 18, 2016 at 5:05 PM, Samed YILDIRIM <samed(at)reddoc(dot)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>;

​https://www.postgresql.org/docs/9.5/static/sql-altertable.html​

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

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ravi Tammineni 2016-08-18 21:19:24 Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?
Previous Message Keith 2016-08-18 21:14:36 Re: What is the best way to create Primary Key on a large table in Postgresql 9.5?