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 1hw6Qu-0001rT-Ms for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2019 15:03:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hw6Qt-00007v-CT for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2019 15:03:55 +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 1hw6Qs-000065-R3 for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2019 15:03:55 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hw6Qp-0006mj-An for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2019 15:03:54 +0000 Received: by mail-ot1-x333.google.com with SMTP id j11so33311754otp.10 for ; Fri, 09 Aug 2019 08:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pdf-com.20150623.gappssmtp.com; s=20150623; h=from:references:in-reply-to:mime-version:thread-index:date :message-id:subject:to:cc; bh=NMQYXo1z3TYYju1JOAMwibzYTDcnlSWjhbGs40HzZRk=; b=wxGZ8KWK55nKjReSWZAUm0aTMIJMTDFMWeNqSklPiykJzc44XMse7MUgvP0kXv+q/t 8MJ31wPeJvPFvIvYKmUlY2ICdfmPl/w07yctprIB4fY2Oi2SfctYkN6nL9sjRIxB/Bwi VvIqaNSN+YdsVljpoyLSMTrUROpAg2HDlPrEwGJzhlU6dDAkk/6oFup0MRPgYKXg5yxT JUyjgszQYGJWhq5gSrZ1+ynMGertIF0AY0cyQrM4EUJ36QVttJFVvvujIJ6w2BHTvvnJ /D8czpnMiT8P1oc4CzDD5yCh++wJvwzA5/ugJi6j37iZMyFjLUcIQKxJGMGzCv7S4fGw 4kCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc; bh=NMQYXo1z3TYYju1JOAMwibzYTDcnlSWjhbGs40HzZRk=; b=L6mffMOnovyti1Z5CJP0hBd8g1GULXenUTqYx+/UIEE5IYfEn3ZqDRpmHe53RFhKjd E8xLUHoZ54yBO880XdHanVKdkfGC6N690NcmFfnBd5cW8RmTAxRjOjj0DFYW7227mdmR OlnlhYQGwuAjdm0/8UggREv83V/VO+JzSsHAfVACoGYtZo7FnGO6+sZlEc9xM41d2z7t q06qzuY25KeJICgHccYpbUSGsGOwjpuXBWi1ToxT+WR9vmSfbE/fAVth3xolhkqcKMDI FpfvelKv4BP+kZ4luClgLmZbOVvccDrvDkFqHGFDUvPRs76iME+p3czg2fzfq1oAC90m uBfw== X-Gm-Message-State: APjAAAWEBL7sd5kGyI4IgmpgJSOar5l+u088+CuCZsZT1BI+DqfBn38q VSkDGXXP0z9VJ9PCaL5lEs+ktjjeu1RheQnOI3RmglqsZlY3fSbXoC0nqQ7ffHM4TUUF0IUpoYp 4IpHKhZXxTNGzx29nEPP6L4Xx2a1XX8rql+o0y9HEtA== X-Google-Smtp-Source: APXvYqy20eoynQg01ZC3PgLjpCqrIOmd1+Hw7YtqkHzkLSdB8fjmLjfN2x5Pvn6DsKeC4lJ+yoYDIQ50/aC+0SVUnPA= X-Received: by 2002:a05:6830:108d:: with SMTP id y13mr19280569oto.255.1565363029609; Fri, 09 Aug 2019 08:03:49 -0700 (PDT) From: "Daniel Fink (PDF)" References: <4b0d1ee711c4079c0544216bb2bdff4b@mail.gmail.com> <05D718F2-9A80-4A9B-A84A-B9C332943AC3@gmail.com> In-Reply-To: <05D718F2-9A80-4A9B-A84A-B9C332943AC3@gmail.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKgM4Cxw8uI2ViB6Ui4Y+Wtnzs6RQImUUTopUvtWbA= Date: Fri, 9 Aug 2019 17:03:47 +0200 Message-ID: <318f956c439d67d600df093b836e690b@mail.gmail.com> Subject: RE: pg_wal fills up on big update query To: Rob Sargent Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000005325a1058fb07b15" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --0000000000005325a1058fb07b15 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Rob, Thanks, I will try. It=E2=80=99s a bit of a bummer though, because I just started to use flywa= ydb to manage migrations, and it wraps all migrations into a single transaction. So I have to do this outside of the tool. Best Regards, Daniel *From:* Rob Sargent [mailto:robjsargent@gmail.com] *Sent:* Wednesday, August 7, 2019 4:22 PM *To:* Daniel Fink (PDF) *Cc:* pgsql-general@lists.postgresql.org *Subject:* Re: pg_wal fills up on big update query On Aug 7, 2019, at 7:34 AM, Daniel Fink (PDF) wrote: Hi all, 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) fro= m another table where I set this new column 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 all space. Then the migration fails and is rolled back. 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 for concurrent queries by keeping a copy of each row. Is my thinking here correct? Thanks in advance and Best Regards, Do the update in small chunks --=20 This message may contain confidential and privileged information. If it has= =20 been sent to you in error, please reply to advise the sender of the error= =20 and then immediately permanently delete it and all attachments to it from= =20 your systems. If you are not the intended recipient, do not read, copy,=20 disclose or otherwise use this message or any attachments to it. The sender= =20 disclaims any liability for such unauthorized use. PLEASE NOTE that all=20 incoming e-mails sent to PDF e-mail accounts will be archived and may be=20 scanned by us and/or by external service providers to detect and prevent=20 threats to our systems, investigate illegal or inappropriate behavior,=20 and/or eliminate unsolicited promotional e-mails (=E2=80=9Cspam=E2=80=9D). = If you have any=20 concerns about this process, please contact us at legal.department@pdf.com= =20 . --0000000000005325a1058fb07b15 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <= div class=3D"WordSection1">

Hi Rob,

=C2=A0

Than= ks, I will try.

It=E2=80=99s a bit of a=C2=A0 bummer though, because I just started to = use flywaydb to manage migrations, and it wraps all migrations into a singl= e transaction.

So I have to do this outside of the tool.

=C2=A0

<= span style=3D"color:#1f497d">Best Regards,

Daniel

=C2=A0

From: Rob Sargent [mailto:robjsargent@gmail.com]
Sent: Wednesday, August 7, 2019 4= :22 PM
To: Daniel Fink (PDF) <daniel.fink@pdf.com>
Cc: pgsql-general@lists.postgresql.org
Su= bject: Re: pg_wal fills up on big update query

=C2=A0

=C2=A0


On Aug 7, 2019, at 7:34 AM, Daniel Fink (PDF) <daniel.fink@pdf.com> wrote:

<= /div>

Hi all,

=C2=A0

I have a migration where I

=C2=B7=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Add a new nullable column to a table

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

=C2=A0

I have also a replication setup running.<= /p>

The database has a size of around 20GB.

While the migration is running, it more than doubles is si= ze and fills up all space.

Then the migration fai= ls and is rolled back.

=C2=A0

What is the best way of keeping this from happening?

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

Is my thinking here correct?

=C2= =A0

Thanks in advance and Best Regards,

=C2=A0

Do= the update in small chunks


This message may contain confidential and privileged information. If i= t has been sent to you in error, please reply to advise the sender of the e= rror and then immediately permanently delete it and all attachments to it f= rom your systems. If you are not the intended recipient, do not read, copy,= disclose or otherwise use this message or any attachments to it. The sende= r disclaims any liability for such unauthorized use. PLEASE NOTE that all = incoming e-mails sent to PDF e-mail accounts will be archived and may be sc= anned by us and/or by external service providers to detect and prevent thre= ats to our systems, investigate illegal or inappropriate behavior, and/or e= liminate unsolicited promotional e-mails (=E2=80=9Cspam=E2=80=9D). If you = have any concerns about this process, please contact us at legal.department@pdf.com. --0000000000005325a1058fb07b15--