Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b4ybw-0002rY-2K for pgsql-admin@arkaria.postgresql.org; Mon, 23 May 2016 22:46:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b4ybv-0004kq-KZ for pgsql-admin@arkaria.postgresql.org; Mon, 23 May 2016 22:46:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1b4ybv-0004kX-3w for pgsql-admin@postgresql.org; Mon, 23 May 2016 22:46:07 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1b4ybs-0004pX-9p for pgsql-admin@postgresql.org; Mon, 23 May 2016 22:46:05 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [216.155.90.98]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 7E362400E60; Mon, 23 May 2016 15:46:02 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id C093047C; Mon, 23 May 2016 18:46:00 -0400 (CLT) Date: Mon, 23 May 2016 18:46:00 -0400 From: Alvaro Herrera To: Natalie Wenz Cc: pgsql-admin Subject: Re: Canceling a vacuum freeze Message-ID: <20160523224600.GA407273@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <365F785B-D974-4210-9F00-51520BE08C07@ebureau.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Natalie Wenz wrote: > Question: > When you cancel a vacuum freeze (or auto vacuum that is running because t= he table's max xid exceeded autovacuum_max_freeze_age) that's running on a = large table, how much work is potentially lost?=20 >=20 > I ask because I have a vacuum freeze running in single-user mode on a dat= abase that is 46 TB, 35 TB of which is one table. I recently migrated it to= 9.5.2 (on a new host), but because so much of the data is in one ridiculou= s table, I dumped the old database, excluding that big table, with pg_dump,= restored everything else using pg_restore, and then used copy statements t= o dump and then load the data from the big table in chunks, so I could dump= and reload that table with some parallelism. I got everything migrated, an= d started logging live data to it. Everything went well until a few weeks l= ater, when the auto vacuum wasn't able to keep up with our transaction load= . The database shut itself down and I got it running in single-user mode an= d started a vacuum freeze. After a while we realized (you probably know whe= re this is going) that the vacuum has to freeze allllllll of the rows in th= e 35 TB table. I'm wondering if it would be worth it to shut it down again = and retune for a more aggressive vacuum. I'm under the impression that some= work would probably be lost, but is there a limit to how much?=20 The problem with freeze vacuums is that they need to scan the whole table to completion. If you cancel one, the only thing you really lose is the portion of the scan that has executed to completion thus far. If you put a second one to work, it will start from scratch; depending on how slow the original one was, it might catch up pretty quickly. The second point to keep in mind is that if there are lots of dead tuples that need to be cleaned up, scanning the indexes might take considerable additional time. You want to avoid this as much as possible by having the largest maintenance_work_mem you can afford (keeping in mind that it's overridden by autovacuum_work_mem); but as I recall the limit is hardcoded at 1GB which is rather unhelpful for very large tables. --=20 =C1lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --=20 Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin