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 1ioZBD-0002Sn-Fs for pgsql-general@arkaria.postgresql.org; Mon, 06 Jan 2020 20:40:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ioZBB-0001kA-S9 for pgsql-general@arkaria.postgresql.org; Mon, 06 Jan 2020 20:40:49 +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 1ioZBB-0001k3-IE for pgsql-general@lists.postgresql.org; Mon, 06 Jan 2020 20:40:49 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ioZB4-0007Ru-VU for pgsql-general@lists.postgresql.org; Mon, 06 Jan 2020 20:40:48 +0000 Received: by mail-pl1-x62b.google.com with SMTP id p27so22266812pli.10 for ; Mon, 06 Jan 2020 12:40:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=P6gZpikbqMgRJZSVKwyKYoJ3eAZ4Jcx/K6m4WYnxoeo=; b=G6aSQXaSG7Vn4E2VlRwz3r16lGSb2A1RtT615xmpq5lfpciivd5YAOQbuOyMYsAPqO DyzYPzkzszLB4FGvlymtmmmMDFiOF34K6O+Jt31kEXbFWTNDeIU0cQ/WDzaMFNGMcSCR fuY6bQKEhhlC8s6PoQggPt/TZi9KEP5UrCuKW1hhNBq8Twipefwe88gZ1htZOTRqiZlR 1NGh824zzP1UEZioKKcKuMAkI3yTet4igRhPm2rB7Y5eLD8Tcsb5Lmz8LYc7AvWADiyz nmvfFbZ0KGM2l9Nkv8LFpXULCDpuNT+GOXThb5e3DAJRMBHxRwPTCLFmfd06qxc2IUGg nBQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=P6gZpikbqMgRJZSVKwyKYoJ3eAZ4Jcx/K6m4WYnxoeo=; b=ijFYU+HdDUHYvygk1x2/RxpxL7p0DPxt+Zck2fTXTNlkQJoMd1dr1ExXTwNGhNo4wa omq+gSTnreBNebnVDA+F9tLXLdYSGPHfMumAtZLJuOfiFreC9T4TOK7FjU5WbTk95Ylp vR4Cwc7t5R8ckFpMkp4kEKwDs/Mm2OMkfEV8+xxJkzS7LGfPbJOfx6hTIEGfIFTND8dW /52tAAnCpQOIQ99zkP+QCitM/uae5XIl4juFNMgFYQR4cRaoCqPgkjupBwuC4c+PNtXB XpXsaS2syApyxxI4tEji8SxeLWfc7V1WsHiDQlM9ot4JklYWH6aFgP4xODMiV7sj3FPe BZzg== X-Gm-Message-State: APjAAAWsuIfCn8C5NTOymYRGftweZo87akAC9lS30xDCkee+kRakQyPz DEYceXmsSHTxPBArsYg9wZw= X-Google-Smtp-Source: APXvYqyMLQUuicelWdbrHBn+hMaTHWCYJmecES+GHjHDqckLT66slAa+LvfG+6bP9oseqFLGi0FbUw== X-Received: by 2002:a17:90a:5108:: with SMTP id t8mr45520563pjh.107.1578343241074; Mon, 06 Jan 2020 12:40:41 -0800 (PST) Received: from [10.106.128.47] ([155.100.47.7]) by smtp.gmail.com with ESMTPSA id t137sm73175533pgb.40.2020.01.06.12.40.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jan 2020 12:40:40 -0800 (PST) From: Rob Sargent Message-Id: <9BB7DDC4-16D7-4137-8F6A-5C4F4F7AB2A0@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_FFD97B1C-70F6-416E-A41B-C2251C0F99D6" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: UPDATE many records Date: Mon, 6 Jan 2020 13:40:39 -0700 In-Reply-To: <91870B50-CDFB-489C-BE01-59B281A9CDCD@gmail.com> Cc: Israel Brewster , Christopher Browne , "pgsql-generallists.postgresql.org" To: Alban Hertroys References: <97518FCA-F286-4A6A-803F-46A109196C71@alaska.edu> <8AB099DA-99B4-421A-BD15-638A367EE722@alaska.edu> <91870B50-CDFB-489C-BE01-59B281A9CDCD@gmail.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_FFD97B1C-70F6-416E-A41B-C2251C0F99D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 6, 2020, at 1:29 PM, Alban Hertroys wrote: >=20 > I think you=E2=80=99re overcomplicating the matter. >=20 > I=E2=80=99d just do it as a single update in one transaction. It=E2=80=99= s only 50M rows. It may take half an hour or so on decent hardware, = depending on how resource-intensive your function is. >=20 I must emphasize: This estimate is HIGHLY dependent on hardware and the = complexity of the table (number of indices, etc). (I suspect there=E2=80=99= 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=E2=80=99re looking at a one-off situation that won=E2=80=99t require = more than a few workarounds - after which you can just run the update = again. >=20 > Ad 1). No harm has been done, it=E2=80=99s a single transaction that = rolled back. >=20 > Alban Hertroys > -- > If you can't see the forest for the trees, > cut the trees and you'll find there is no forest. --Apple-Mail=_FFD97B1C-70F6-416E-A41B-C2251C0F99D6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jan 6, 2020, at 1:29 PM, Alban Hertroys <haramrae@gmail.com> = wrote:

I think = you=E2=80=99re overcomplicating the matter.

I=E2=80=99d = just do it as a single update in one transaction. It=E2=80=99s 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=E2=80=99s 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=E2=80=99re looking at a one-off situation that won=E2=80=99t= require more than a few workarounds - after which you can just run the = update again.

Ad 1). No = harm has been done, it=E2=80=99s 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.

= --Apple-Mail=_FFD97B1C-70F6-416E-A41B-C2251C0F99D6--