pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Alban Hertroys <haramrae@gmail.com>
Cc: Israel Brewster <ijbrewster@alaska.edu>
Cc: Christopher Browne <cbbrowne@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: UPDATE many records
Date: Mon, 6 Jan 2020 13:40:39 -0700
Message-ID: <9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com> (raw)
In-Reply-To: <91870B50-CDFB-489C-BE01-59B281A9CDCD@gmail.com>
References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu>
	<CAFNqd5X5FXzFL+vhx=mg40gv0nPV9cJ6yJZU9f5hFYCUbkg31Q@mail.gmail.com>
	<8AB099DA-99B4-421A-BD15-638A367EE722@alaska.edu>
	<91870B50-CDFB-489C-BE01-59B281A9CDCD@gmail.com>



> On Jan 6, 2020, at 1:29 PM, Alban Hertroys <haramrae@gmail.com> wrote:
> 
> I think you’re overcomplicating the matter.
> 
> I’d just do it as a single update in one transaction. It’s only 50M rows. It may take half an hour or so on decent hardware, depending on how resource-intensive your function is.
> 
I must emphasize: This estimate is HIGHLY dependent on hardware and the complexity of the table (number of indices, etc).  (I suspect there’s a correlation between table size (business value) and number of indices)

> If that fails[1], only then would I start looking into batching things. But then you still need to figure out why it fails and what to do about that; if it fails it will probably fail fast, and if not, then you’re looking at a one-off situation that won’t require more than a few workarounds - after which you can just run the update again.
> 
> Ad 1). No harm has been done, it’s a single transaction that rolled back.
> 
> Alban Hertroys
> --
> If you can't see the forest for the trees,
> cut the trees and you'll find there is no forest.

view thread (35+ messages)  latest in thread

Message-ID: <9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com>
Permalink:  ../9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com/
Also on:    postgresql.org/message-id/9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com

 · 

reply

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: robjsargent@gmail.com, haramrae@gmail.com, ijbrewster@alaska.edu, cbbrowne@gmail.com
  Subject: Re: UPDATE many records
  In-Reply-To: <9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com>
  References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu> <CAFNqd5X5FXzFL+vhx=mg40gv0nPV9cJ6yJZU9f5hFYCUbkg31Q@mail.gmail.com> <8AB099DA-99B4-421A-BD15-638A367EE722@alaska.edu> <91870B50-CDFB-489C-BE01-59B281A9CDCD@gmail.com> <9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com>

* 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