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 1jVj4v-0007J6-R4 for pgsql-general@arkaria.postgresql.org; Mon, 04 May 2020 21:56:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jVj4u-0007dE-NB for pgsql-general@arkaria.postgresql.org; Mon, 04 May 2020 21:56:44 +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 1jVj4t-0007d7-LW for pgsql-general@lists.postgresql.org; Mon, 04 May 2020 21:56:44 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jVj4p-0004fc-O1 for pgsql-general@postgresql.org; Mon, 04 May 2020 21:56:43 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 0493B5C00AD; Mon, 4 May 2020 17:56:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 04 May 2020 17:56:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=B m9clWhzs8WMCAcLaEGGJPZU2pT1xmnUqL7An/ek3Tw=; b=clTaCFSIMOE3Rq+s6 SC2etscbzqAVWfn/3idfKI0xsWPmLxH9yVqEr484siKRhPpJKp8HvsIwJzpizhpT z8KUH04MnRhpe1hyorn/FwfLvHT/PrggvT/9mI4ZMAkttB15NJEd52ZZ7cJRCNJv 0akeM33ga4/NeTNvx9gU/98EoypEBFzs9xtiIiY1Qt4fpJmC6KTaPI5BSqfCZch5 fncp8FazhF0yP75uj2Vhuu0gqr8bDkcRJqLzfGdz18c4dckWs5HMPaSy5MfOA5eG ANAe5mkeiF4/D86Q8ZhPhQHDIK6nmJwSxHLSP0b7bEiHjR5oQCekaeoSeyLxMZYg QF7FA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm2; bh=Bm9clWhzs8WMCAcLaEGGJPZU2pT1xmnUqL7An/ek3 Tw=; b=TKbkrSsDAfieaEI9msgJqQZKhAcBQMhqDjQrodm52tqkTtsIY04YlERhP nzNgtpuZ/wA3yYyWogKugvONV7mCEE5UA6Cln1gSMmEtBocyiqmybb2F0INB0oBN zAFFkom3m3QJH8X2YtE3xvH1GBDb6Gd67xPcZc5uDcQjmwFPgeVvZira03844AQr ptl1bc/Qy3ncwX2ofXCt9Gic0eGd200+61515BoN61q8xJlE7zx3OVlA8cAHRKr2 BLYNYnxnEM+VOJOl8BpwTPHYiDA4QEQumORytCI3WGhoTRBMvita5EPPdUCsqftp JPFQjS5DNVVV8aRqTuaT/AxCDzMOw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrjeehgddtfecutefuodetggdotefrodftvf 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 4CC0E3280059; Mon, 4 May 2020 17:56:27 -0400 (EDT) Subject: Re: Thoughts on how to avoid a massive integer update. To: "Fehrle, Brian" , "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: <129e882d-fe4c-0ce9-1966-acbcbf94c309@aklaver.com> Date: Mon, 4 May 2020 14:56:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.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 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/4/20 2:32 PM, Fehrle, Brian wrote: > Hi all, > > This is a shot in the dark in hopes to find a magic bullet to fix an > issue I have, I can’t personally think of any solution myself. > > I have a database with hundreds of terabytes of data, where every table > has an integer column referencing a small table. For reasons out of my > control and cannot change, I NEED to update every single row in all > these tables, changing the integer value to a different integer. > > Since I have to deal with dead space, I can only do a couple tables at a > time, then do a vacuum full after each one. Why? A regular vacuum would mark the space as available. More below. > Another option is to build a new table with the new values, then drop > the old one and swap in the new, either way is very time consuming. > > Initial tests suggest this effort will take several months to complete, > not to mention cause blocking issues on tables being worked on. > > Does anyone have any hackery ideas on how to achieve this in less time? > I was looking at possibly converting the integer column type to another > that would present the integer differently, like a hex value, but > everything still ends up requiring all data to be re-written to disk. In > a well designed database (I didn’t design it :) ), I would simply change > the data in the referenced table (200 total rows), however the key being > referenced isn’t just an arbitrary ID, it’s actual ‘data’, and must be > changed. I'm not following above. Could you show an example table relationship? > > Thanks for any thoughts or ideas, > > * Brian F > -- Adrian Klaver adrian.klaver@aklaver.com