Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iowCU-0005Yc-06 for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 21:15:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iowCS-0002u9-NF for pgsql-general@arkaria.postgresql.org; Tue, 07 Jan 2020 21:15:40 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iowCS-0002u2-Dd for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 21:15:40 +0000 Received: from athena.simkin.ca ([2607:f040:1001:2::ff:2]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iowCO-00064Q-LC for pgsql-general@lists.postgresql.org; Tue, 07 Jan 2020 21:15:40 +0000 Received: from skynet.simkin.ca (d205-250-70-177.bchsia.telus.net [205.250.70.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by athena.simkin.ca (Postfix) with ESMTPSA id 29A01DC696EB for ; Tue, 7 Jan 2020 13:15:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.simkin.ca; s=athena; t=1578431734; bh=4GXJQNIKNjL3G4sCKwPg7MoYH020rrXADwtwoVGY5W4=; h=Subject:From:To:Date:From:To:Subject:Date:Reply-To; b=pkvS+NtjHIV1Nu7vB6ypyBoyActm/0ppIwvlVjdrTa395ZlOx8gK+AyqTlAIUIlmc pN2WcWAiEjTvfRvwuOlgDuehLTmjE9W1dxHRr2axa7fmBfGIuW3JTP/XS6NB3wKgOY LYgFRVQniYftRyFhaaHQL/3nOc7UwPFiaugDOsEGkebEIkb7jXfa0upXYsSiW2usQW mJehdU3Mu6gh0O9MVI8gNNN2EozRUitrqdlP9bSUfT3R32Wa2RVdTxDe4up1CDDcCK WnFNYeUXsxWk0DMzfimIpHPGFznPSN6+vKqCe5xl1g6mUgQldlR1eq8EvtVRKMyjpP 5FaGB/EF3gjuw== Received: from skynet.simkin.ca (skynet.simkin.ca [IPv6:::1]) by skynet.simkin.ca (Postfix) with ESMTP id EBC4F105B7D9B for ; Tue, 7 Jan 2020 13:15:33 -0800 (PST) Message-ID: <365cae454cea40ca594e9b4b899fb82958f3e17d.camel@lists.simkin.ca> Subject: Re: UPDATE many records From: Alan Hodgson To: "pgsql-general@lists.postgresql.org" Date: Tue, 07 Jan 2020 13:15:33 -0800 In-Reply-To: References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu> <86f7f7160d10a726541fd689c5a518102e3f50c5.camel@lists.simkin.ca> Content-Type: text/plain; charset="UTF-8" X-PGP-Key: fp="EF82 6F8D A3BA A096 FFA3 05F2 A7A0 40A5 34E5 AA0B"; id="0x34E5AA0B"; get= User-Agent: Evolution 3.32.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2020-01-07 at 11:58 -0900, Israel Brewster wrote: > > > Really? Why? With the update I am only changing data - I’m not adding > any additional data, so the total size should stay the same, right? > I’m obviously missing something… :-) > PostgreSQL keeps the old row until it gets vacuumed, as it needs to be visible to other transactions. Not only that, but every index record gets updated to point to the location of the new data row too (excluding HOT), and those old index blocks also need to get vacuumed. And none of those rows can get removed until your update finishes. I know this isn't universally true with HOT and fillfactor etc. but with an update this big I think it's safe to say most of the space will get doubled. Plus you'll get a ton of write-ahead logs.