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 1hw74H-0003Vu-Bl for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2019 15:44:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hw74E-0007b8-ND for pgsql-general@arkaria.postgresql.org; Fri, 09 Aug 2019 15:44:34 +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 1hw74E-0007b0-CL for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2019 15:44:34 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hw74B-00079g-QZ for pgsql-general@lists.postgresql.org; Fri, 09 Aug 2019 15:44:34 +0000 Received: by mail-pf1-x441.google.com with SMTP id t16so46232594pfe.11 for ; Fri, 09 Aug 2019 08:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=pqXmry0WvD3LyJf1oyh6747sKoKY0R0Q4TnF3m32xwg=; b=luAMkMpp49Qoe9CPAQV81+nqYd0uEjL2jvb3zDBNbt1JEO3EycNVFYBa2AsXoc3Vil fl6aW35KLEDAHHYolv2vE7r3lA9k1MS7DUSd7Gr9B2Uoztln9j8N2tozcikqTGrtfOsB Htg++f5VmLLJhTSWtFqLOIX8s6dGNzPsrmaafLPIz4Uom4OboLIw1RLoAuI5QiYm3ujR cVmyGrMydAsQ5wJ6Dugb+kZAiw7C19Tweys3aP9R3rmJQF0F4+SPYdsut12XrZ1Ax8sM LkqhebhQWiDDd6XlSpb+dcPkJqLmSLgQBYC3+9cswFB3LVwX1WfTcIvEkROcY2Pbhc08 myeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=pqXmry0WvD3LyJf1oyh6747sKoKY0R0Q4TnF3m32xwg=; b=kTJz2haVpTylxRFBzA5FDsY+wJYnrNeTLXrNAVwUFxgQXTOWDQFpUN5GHI9ikIYaTd edlE54v+gTZE+jfkn1UuWzfiQ66j8m5rIdwEHHvrOZjmjwaFHEXAuChFdMCTQI79Wh7V g28bAgMBkUoI7Hxpkb1xQkxJuS5/i1ycMueVnBoAuUMiVOGmr3ENejCZeHthpNwfCPkx 3DGn2e4ejC7yUXRc7UVpAWpv6O5fVzDYCNRi7Fvz4ENKUHOuMaowVUQb+JYaiSgQm/kb OV+0DTrmhzWoxqeqScN7aCiHzvta7s+2yLMw5/ohtK3VOU9aELw8JU2stVvGeJjpziYS cPxA== X-Gm-Message-State: APjAAAVxfrdPJH/s3sNFbddHhXEP5T/53MbHBvfvDh+XajUa/LyEN2mF gAsuIvpw0BCHUgnoPdDXMar4kJGu X-Google-Smtp-Source: APXvYqwxLn764wpI5JHomxV05dnBGYwmNZfS46qIttrAWE7PvsA8hzf4172OgSiUgSJpe8f75M40gA== X-Received: by 2002:a62:642:: with SMTP id 63mr22265261pfg.257.1565365469464; Fri, 09 Aug 2019 08:44:29 -0700 (PDT) Received: from [10.104.134.41] ([155.100.47.1]) by smtp.gmail.com with ESMTPSA id f15sm7543909pje.17.2019.08.09.08.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Aug 2019 08:44:28 -0700 (PDT) Subject: Re: pg_wal fills up on big update query To: "Daniel Fink (PDF)" Cc: pgsql-general@lists.postgresql.org References: <4b0d1ee711c4079c0544216bb2bdff4b@mail.gmail.com> <05D718F2-9A80-4A9B-A84A-B9C332943AC3@gmail.com> <318f956c439d67d600df093b836e690b@mail.gmail.com> From: Rob Sargent Message-ID: Date: Fri, 9 Aug 2019 09:44:27 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <318f956c439d67d600df093b836e690b@mail.gmail.com> Content-Type: multipart/alternative; boundary="------------9E3F11A3D43EFD990BDA50D9" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------9E3F11A3D43EFD990BDA50D9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit flyway is an excellent tool, I use it too.  Just make a series of migrations. On 8/9/19 9:03 AM, Daniel Fink (PDF) wrote: > > Hi Rob, > > Thanks, I will try. > > It’s a bit of a  bummer though, because I just started to use flywaydb > 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 > > ·Add a new nullable column to a table > > ·update almost every row in this big table (8 million rows) from > 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 > > > /This message may contain confidential and privileged information. If > it has been sent to you in error, please reply to advise the sender of > the error and then immediately permanently delete it and all > attachments to it from 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 sender 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 scanned by us and/or by > external service providers to detect and prevent threats to our > systems, investigate illegal or inappropriate behavior, and/or > eliminate unsolicited promotional e-mails (“spam”). If you have any > concerns about this process, please contact us at > //legal.department@pdf.com/ /./ --------------9E3F11A3D43EFD990BDA50D9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

flyway is an excellent tool, I use it too.  Just make a series of migrations.

On 8/9/19 9:03 AM, Daniel Fink (PDF) wrote:

Hi Rob,

 

Thanks, I will try.

It’s a bit of a  bummer though, because I just started to use flywaydb 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) <daniel.fink@pdf.com>
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) <daniel.fink@pdf.com> wrote:

Hi all,

 

I have a migration where I

·       Add a new nullable column to a table

·       update almost every row in this big table (8 million rows) from 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


This message may contain confidential and privileged information. If it has been sent to you in error, please reply to advise the sender of the error and then immediately permanently delete it and all attachments to it from 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 sender 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 scanned by us and/or by external service providers to detect and prevent threats to our systems, investigate illegal or inappropriate behavior, and/or eliminate unsolicited promotional e-mails (“spam”). If you have any concerns about this process, please contact us at legal.department@pdf.com.
--------------9E3F11A3D43EFD990BDA50D9--