Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jy1kz-0000hx-3C for pgsql-general@arkaria.postgresql.org; Tue, 21 Jul 2020 23:33:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jy1kw-0007TA-AC for pgsql-general@arkaria.postgresql.org; Tue, 21 Jul 2020 23:33:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jy1ku-0007Sx-OR for pgsql-general@lists.postgresql.org; Tue, 21 Jul 2020 23:33:06 +0000 Received: from [64.147.123.19] (helo=wout3-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jy1km-0004iO-BT for pgsql-general@postgresql.org; Tue, 21 Jul 2020 23:33:03 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 658E3EEA; Tue, 21 Jul 2020 19:32:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 21 Jul 2020 19:32:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=t aNAz1cFgV8eNJXYiZ+yYXzEZdOAtdG2l3iGY1c/X9w=; b=RfEXahXnwtFKJjjSc MEqJAGkcwG5KEfr3PgeG0Uo++vf6cxXnMPVqtjMiIwTLTiHy1IDXzpyazAxrXsYw E+OrGHQq1pSPQ1b3gftWZkbFErmhZyKzomnT9lvy+3emTZyyOrIj+bKrvXmtzXhL AAqxsWTnQ5z3Yib7Fl8wRMlo31pEY5zdD8WJ0JiSnAc7MoFFq5li64TvqCJv8WdX JZFZmXvJD/2TnbxB7G3IrnKiguXJOc1QCADiOWXfF9Tsxe3Cktsm44fo2UsleLAA snHaR+BNrop+z5S6L8O0rUWs3re9BnqEfpZU5Z20Wfrse3CD9hwfPn3Xd/hCAkrL WmU2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=taNAz1cFgV8eNJXYiZ+yYXzEZdOAtdG2l3iGY1c/X 9w=; b=NVTj8GuwIQr23xVNwuGlK3Fz8NjQ8RrAFuuqZ0UhfSD6AJCFXHNxvqbq3 sWDjNjtrQG5JOK7txoKAizklsUnt50mPcSGyb23IWxVzS6k+plPNI01aqHm7GCln SSR1p1o7Bn3tHBFHH3Bl3b3gL/Z577IGjMSjvvLaKO5eaMifNYlALI/KCPyQ96Yb N5OZEqjAVcQGKSlczsjSC5snPiOQOFGjitblA950gsOELNwTBd4R5oYy/mRLxTXh kfJxssiCrXoobbkGGbYVhETfKeWoziXEMlwMY60TNBEyeSvYCi0oPHZZzW6hlVVg fjFaoD8QoeeyQMsRwYhLvPVfttW+w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrgeekgddvfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepveevfeevfeeugeffkeekhfegieeufffgteeujedvgffh ueejjefhkeejleegtdegnecukfhppeejhedrudejvddrhedrvdefudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 0A20230600A3; Tue, 21 Jul 2020 19:32:41 -0400 (EDT) Subject: Re: Switching Primary Keys to BigInt To: Mohamed Wael Khobalatte , Michael Lewis Cc: pgsql-general References: From: Adrian Klaver Message-ID: <14e326d2-7ee3-be5a-feb5-4e6c43425fb8@aklaver.com> Date: Tue, 21 Jul 2020 16:32:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.19 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 7/21/20 2:18 PM, Mohamed Wael Khobalatte wrote: >>  > test_(aklaver)5432> alter table change_seq alter COLUMN id set data type >> bigint; >> ALTER TABLE >> test_(aklaver)5432> \d change_seq >>                              Table "public.change_seq" >>   Column |  Type  | Collation | Nullable |                Default >> --------+--------+-----------+----------+---------------------------------------- >> >>   id     | bigint |           | not null | >> nextval('change_seq_id_seq'::regclass) >> Indexes: >>      "change_seq_pkey" PRIMARY KEY, btree (id) > > This is significant downtime, since it locks exclusively, no? We want to > avoid that. Yeah, I thought the int --> bigint would not do a table rewrite. Testing showed otherwise. Forget that idea. > > > Side note- EOL for 9.6 is coming next year so just a plug for > upgrading when possible, perhaps utilizing pglogical to get to v11 or 12. > > Yep, we are painfully aware. The id growth will beat us to it, so we > need to deal with that first. > > -- Adrian Klaver adrian.klaver@aklaver.com