Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1baUQA-0005oF-CG for pgsql-admin@arkaria.postgresql.org; Thu, 18 Aug 2016 21:00:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1baUQ9-0002BA-IZ for pgsql-admin@arkaria.postgresql.org; Thu, 18 Aug 2016 21:00:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1baUQ8-0002Av-Ts for pgsql-admin@postgresql.org; Thu, 18 Aug 2016 21:00:13 +0000 Received: from mail-sn1nam02on0112.outbound.protection.outlook.com ([104.47.36.112] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.0:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1baUQ5-0003L3-O8 for pgsql-admin@postgresql.org; Thu, 18 Aug 2016 21:00:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aligntech.onmicrosoft.com; s=selector1-partner-aligntech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EJP0SIM5CqtDAgShAX7eKzw0t29yiLP2e+KuMp5fYPc=; b=LQGDnUwaa6zXILUEVNni/vhREvaVbqIMBHE3sM1MGBNe/dv470VgfxEurzfr6pryPSW8AlkzDzyl0TFmBcULOYpHvUO22AvsmQ74gJNgBx+U2V7p863Vz8/Nvd0ipiib10aiLBTDYEe8kC0oLDFnfDqHCLCeQyfxjRTy9YMmeq8= Received: from BN1PR02MB231.namprd02.prod.outlook.com (10.242.214.148) by BN1PR02MB230.namprd02.prod.outlook.com (10.242.214.142) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Thu, 18 Aug 2016 21:00:06 +0000 Received: from BN1PR02MB231.namprd02.prod.outlook.com ([169.254.3.43]) by BN1PR02MB231.namprd02.prod.outlook.com ([169.254.3.43]) with mapi id 15.01.0557.022; Thu, 18 Aug 2016 21:00:06 +0000 From: Ravi Tammineni To: "pgsql-admin@postgresql.org" Subject: What is the best way to create Primary Key on a large table in Postgresql 9.5? Thread-Topic: What is the best way to create Primary Key on a large table in Postgresql 9.5? Thread-Index: AdH5k3HzUT1bItMsT0WpYrt/ypdEFQ== Date: Thu, 18 Aug 2016 21:00:06 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rtammineni@partner.aligntech.com; x-originating-ip: [216.34.141.80] x-ms-office365-filtering-correlation-id: 5bf77a2f-8db5-4b97-2cfd-08d3c7aaa1fd x-microsoft-exchange-diagnostics: 1;BN1PR02MB230;6:DqdXUoodUXd9OvFcifkMO/NGmleM4rE8vvhLmfOPrTCU4EBNTcu1g5zbsTKgG3rhqYkXxAHgFyymqmIg/IFFu6rXB4guMi8IGZNCeYM8ids6sZG4UMvzlOOtaIxMRRjDQi8apfexwNlC9JXWo3F8dowykNO0mAZOp0SZUUGBNGthb0dB7eMZbxpbOV6HFqCNoLWtR9AdxeCs1WE37gKAoJFa3l2S/EwWC67+2lhZpNtsMfs9XG3DXRLbp4mY4408SjjEWDm7Wyth3U+6SR1wsr9pmE+9u+NaTWYyPc1X+bP+x7v3yvldurRXqmyVyHfu;5:48vjSVt8vfNRxRXEfmf4DW7Ak613EmZiSUOF/Nq/Byk5gpwakmipTPV2H+m8CtHgmqjn/AXuxutqQF6bohxUUPEyXothlSGLIgptaClgHrdgZq92nge6AX4X/BCuiSKMDfmoG7Jyad01U/A3ZDx9Ow==;24:dlqTIx41g93RW7vknw9vjnpOrNO7Nuol1na74hC9lsrjI9Akzj8GdQk8oINOORsJ9fS10JsP5FD/sZQmLMK3CS/EFHH06wd11r/s+lqIHos=;7:4HfrX2ZczNpomKpkdOeoNh/IKiS2tPmli2W7g7w01isOy5O2a9UJwROP3jWtNmJouHPORIyo+Otj7l2zdvHXxJPYJ0/CqcFdiOADh1MvImvw/71TGLJg1g3zsDHixhaUE1cZYdGC2l1W8lQ7GQNAj5NbBTi3bH2vAiSBJHl5V0SUMSRNbVNlVzEHgk62fwdRBk5nQGSQTR+9Xoeaiq2Pwg+rrk+ALTPuZHGvo3HbZVlMxkhrPMkmM+Hy+YhAVUFg x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB230; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(21748063052155); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6043046)(6042046);SRVR:BN1PR02MB230;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB230; x-forefront-prvs: 0038DE95A2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(199003)(189002)(10400500002)(558084003)(106356001)(101416001)(5002640100001)(189998001)(19580395003)(54356999)(19625215002)(7696003)(68736007)(110136002)(3280700002)(229853001)(33656002)(3660700001)(50986999)(2351001)(586003)(7736002)(9686002)(7846002)(16236675004)(2906002)(76576001)(81156014)(122556002)(86362001)(99286002)(11100500001)(107886002)(92566002)(6116002)(87936001)(66066001)(5630700001)(2501003)(74316002)(5640700001)(8936002)(790700001)(8676002)(450100001)(2900100001)(102836003)(81166006)(105586002)(19300405004)(3846002)(97736004)(15975445007)(43043002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN1PR02MB230;H:BN1PR02MB231.namprd02.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:0;MX:1;LANG:en; received-spf: None (protection.outlook.com: partner.aligntech.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BN1PR02MB23134DCFEF3087FA7DAF0EC80150BN1PR02MB231namprd_" MIME-Version: 1.0 X-OriginatorOrg: partner.aligntech.com X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2016 21:00:06.2103 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9ac44c96-980a-481b-ae23-d8f56b82c605 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR02MB230 X-Pg-Spam-Score: -0.5 (/) 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 --_000_BN1PR02MB23134DCFEF3087FA7DAF0EC80150BN1PR02MB231namprd_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 colu= mn and i don't want to lock the table because this is highly transactional = database. Thanks ravi --_000_BN1PR02MB23134DCFEF3087FA7DAF0EC80150BN1PR02MB231namprd_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

 

Thanks

ravi

--_000_BN1PR02MB23134DCFEF3087FA7DAF0EC80150BN1PR02MB231namprd_--