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 1hvMpR-0006Zm-Uq for pgsql-general@arkaria.postgresql.org; Wed, 07 Aug 2019 14:22:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hvMpQ-0006iN-NZ for pgsql-general@arkaria.postgresql.org; Wed, 07 Aug 2019 14:22:12 +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 1hvMpQ-0006fQ-Ah for pgsql-general@lists.postgresql.org; Wed, 07 Aug 2019 14:22:12 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hvMpO-0002DB-0l for pgsql-general@lists.postgresql.org; Wed, 07 Aug 2019 14:22:11 +0000 Received: by mail-ot1-x331.google.com with SMTP id s20so39449183otp.4 for ; Wed, 07 Aug 2019 07:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=j5JNDiuqAZIUoLV9o5S4ZkLw46XaXHZxtm9fLSq25TM=; b=dbv1ga7fzZIdj3Ci27vQMc1JrLbkdKYRhtObKcj/8fQawg7lc8T99kPqFY/mQi/ZKw PA6Pz8UDMnXHiXUwRaDUI98nnjqfQbVGjuKnI8AZoLSWtYxV2jsaEBpp9t7jdTAgfIkx BLO6DPuSDnDyfVVE5x4RsuHlun2A+ew6rcA4YkwiTElcUrH5sx8mdLTxr5cwrHFjQ1oF Ls6PdTfWCwVTDfvFqlKAQ3Or1KAVCms8OI2LDJXSeqkMYcmy5396sVC+l1PXzyX7H2Xn IhHoL6ajsBJDgbhxkjVvqnuXOGSm5uSeyVmx/btvauvmVS9SC5MK/iMtQKzhszdJMZ0j cHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=j5JNDiuqAZIUoLV9o5S4ZkLw46XaXHZxtm9fLSq25TM=; b=M2Xv+07iIgC4cGtPsv3bXU9m5qISfWsjIEJv4sXBiw9panSdzlJWJlqxirB4ddyb0x q1i1OrAbGXFiywtS/9kouWWllFme0zxL3V1NO9LI6++JKEH9qLIuya0FXG3+3iHFaa5R uozLR/sFDdBInIH11b5yGOxAKCxQgCGqPV5pVrClg2LmmrTy/24eyaPb6ujjb9zvJ+QQ TrPPumCGj7Pm5sgj4QnfOl2QZOPgHHw2EBjPmX5VyJto4Nk91LT80Lm+9QSza+rMv4Sv D6zqxUU5qpLuZus3IyEtAEjaSqTlW7bK9QTExVzuZAxMYbVJ5tZ7NAIUq6YdrVs8ndnU Da4A== X-Gm-Message-State: APjAAAXe5HP+4Nil9OSrcGJGQJPHNPvNPnw3Ypp8LpOB8dL0ft7tFyxh QSq7IGBXUpqoLb0T37xdzYgaBAWG X-Google-Smtp-Source: APXvYqwoVWl15mti1qVIqogaBqcWkZCVmbXy4GygyyDK2zl7ccO9wdmAP1CLyrM4M0uHnLXkhjjbog== X-Received: by 2002:a5d:8404:: with SMTP id i4mr9443475ion.146.1565187727494; Wed, 07 Aug 2019 07:22:07 -0700 (PDT) Received: from [192.168.1.147] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id j25sm122422867ioj.67.2019.08.07.07.22.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 07:22:06 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-A13926B7-2CDF-43EC-9BAE-362D3302B210 Mime-Version: 1.0 (1.0) Subject: Re: pg_wal fills up on big update query From: Rob Sargent X-Mailer: iPhone Mail (16F203) In-Reply-To: <4b0d1ee711c4079c0544216bb2bdff4b@mail.gmail.com> Date: Wed, 7 Aug 2019 08:22:06 -0600 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: 7bit Message-Id: <05D718F2-9A80-4A9B-A84A-B9C332943AC3@gmail.com> References: <4b0d1ee711c4079c0544216bb2bdff4b@mail.gmail.com> To: "Daniel Fink (PDF)" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-A13926B7-2CDF-43EC-9BAE-362D3302B210 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Aug 7, 2019, at 7:34 AM, Daniel Fink (PDF) wrote:= >=20 > Hi all, > =20 > I have a migration where I > =C2=B7 Add a new nullable column to a table > =C2=B7 update almost every row in this big table (8 million rows) f= rom another table where I set this new column > =20 > I have also a replication setup running. > The database has a size of around 20GB. > While the migration is running, it more than doubles is size and fills up a= ll space. > Then the migration fails and is rolled back. > =20 > What is the best way of keeping this from happening? > My current idea is to lock both tables completely from access (the queried= and the updated one) so that postgresql does not have to ensure isolation f= or concurrent queries by keeping a copy of each row. > Is my thinking here correct? > =20 > Thanks in advance and Best Regards, >=20 Do the update in small chunks= --Apple-Mail-A13926B7-2CDF-43EC-9BAE-362D3302B210 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Aug 7, 2019, at 7:34 AM, Daniel Fink (PDF) &l= t;daniel.fink@pdf.com> wrote:<= br>

Hi all,

 

I have a migration where= I

=C2=B7 &nbs= p;       Add a new nullab= le column to a table

=C2=B7         update almost every row in this big table (8 million rows) from another ta= ble where I set this new column

 

I have also a replication setup running.

The database has a size of around 20GB.

Whil= e the migration is running, it more than doubles is size and fills up all sp= ace.

Then the migration fails and is rolled back.<= /p>

 

What is the best w= ay of keeping this from happening?

My current idea= is to lock both tables completely from access (the queried and the updated o= ne) so that postgresql does not have to ensure isolation for concurrent quer= ies by keeping a copy of each row.

Is my thinking h= ere correct?

 

Than= ks in advance and Best Regards,


Do the update in small chunks= --Apple-Mail-A13926B7-2CDF-43EC-9BAE-362D3302B210--