From: Alan Hodgson <ahodgson@lists.simkin.ca>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: UPDATE many records
Date: Tue, 07 Jan 2020 13:15:33 -0800
Message-ID: <365cae454cea40ca594e9b4b899fb82958f3e17d.camel@lists.simkin.ca> (raw)
In-Reply-To: <F9677E36-0B9C-4C5C-9251-568F3CEC1827@alaska.edu>
References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu>
<CY4PR0601MB3763A96602AE90077A6DC060D53F0@CY4PR0601MB3763.namprd06.prod.outlook.com>
<BB3FB79A-8172-43E2-A731-0D42B78FB569@alaska.edu>
<86f7f7160d10a726541fd689c5a518102e3f50c5.camel@lists.simkin.ca>
<F9677E36-0B9C-4C5C-9251-568F3CEC1827@alaska.edu>
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ahodgson@lists.simkin.ca
Subject: Re: UPDATE many records
In-Reply-To: <365cae454cea40ca594e9b4b899fb82958f3e17d.camel@lists.simkin.ca>
References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu> <CY4PR0601MB3763A96602AE90077A6DC060D53F0@CY4PR0601MB3763.namprd06.prod.outlook.com> <BB3FB79A-8172-43E2-A731-0D42B78FB569@alaska.edu> <86f7f7160d10a726541fd689c5a518102e3f50c5.camel@lists.simkin.ca> <F9677E36-0B9C-4C5C-9251-568F3CEC1827@alaska.edu> <365cae454cea40ca594e9b4b899fb82958f3e17d.camel@lists.simkin.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox