Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1baUX0-0006S4-Hy for pgsql-admin@arkaria.postgresql.org; Thu, 18 Aug 2016 21:07:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1baUX0-0000l0-0F for pgsql-admin@arkaria.postgresql.org; Thu, 18 Aug 2016 21:07:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1baUVJ-0006M0-1R for pgsql-admin@postgresql.org; Thu, 18 Aug 2016 21:05:33 +0000 Received: from forward5j.cmail.yandex.net ([2a02:6b8:0:1630::18]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1baUVG-0004Le-42 for pgsql-admin@postgresql.org; Thu, 18 Aug 2016 21:05:32 +0000 Received: from mxback6h.mail.yandex.net (mxback6h.mail.yandex.net [84.201.186.15]) by forward5j.cmail.yandex.net (Yandex) with ESMTP id A3B9E20BE4; Fri, 19 Aug 2016 00:05:27 +0300 (MSK) Received: from web30h.yandex.ru (web30h.yandex.ru [84.201.187.164]) by mxback6h.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 2FLmeDRtMK-5RxGAbbo; Fri, 19 Aug 2016 00:05:27 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reddoc.net; s=mail; t=1471554327; bh=OA6DEL6YPJK2FxJx+fEaE8qNhgn/4PnV0KPWROzqxLg=; h=From:To:In-Reply-To:References:Subject:Message-Id:Date; b=D15GGXEka/+V9ZCvwJLMig0YN++jzvO2Unc0uJFN05enM8y9sKZAI4rVdTQ8t2WpU d1IChGDDb7UOPa1QGowU8xsJXrbaDRwtzFXbtbtWk+u/WvMkwq0S/bXsmzu8e/eC/Q ikS42B8a0h0kZWLNmbbhsI3bytVjaYOBGWNJLueA= Authentication-Results: mxback6h.mail.yandex.net; dkim=pass header.i=@reddoc.net Received: by web30h.yandex.ru with HTTP; Fri, 19 Aug 2016 00:05:27 +0300 From: Samed YILDIRIM To: Ravi Tammineni , "pgsql-admin@postgresql.org" In-Reply-To: References: Subject: Re: What is the best way to create Primary Key on a large table in Postgresql 9.5? MIME-Version: 1.0 Message-Id: <569661471554327@web30h.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 19 Aug 2016 00:05:27 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=utf-8 X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org

Hi Ravi,

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

Best regards.



İyi çalışmalar.
Samed YILDIRIM


19.08.2016, 00:01, "Ravi Tammineni" <rtammineni@partner.aligntech.com>:

 I have to create a primary key on a large table (~100Million records). What is the best and fastest way to create pkey? This column is a sequence column and i don't want to lock the table because this is highly transactional database.

 Thanks

 ravi