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.92) (envelope-from ) id 1jCpIo-0000N3-EJ for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 18:44:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jCpIl-0008Ob-5F for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2020 18:44:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jCpIk-0008OS-LZ for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2020 18:44:54 +0000 Received: from mail-qv1-xf43.google.com ([2607:f8b0:4864:20::f43]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jCpId-0003Uw-6e for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2020 18:44:53 +0000 Received: by mail-qv1-xf43.google.com with SMTP id v38so1121831qvf.6 for ; Fri, 13 Mar 2020 11:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xTc3bFuoPofuRsvGftSoMen5rimqO1TbZ2F0a38SQEA=; b=e1Xn01PUyph/qXUfahvfZBnY7VQG9pXpq3nEbHXJdky1/P7lndcgpwe+INbf4A0iFa 48PFA2sNaSbK0JAPx1Pk8xKGN/rCyP5XkCXoehX24CxoFo6hvbwbcx5hzbce+RR4B0Uy bFNpBsUtf5RRyKq632zAmdN3wPaGTzCCmwNVu1nDRhp7pDl+oCmuTDJnbmF8j8s4qj9X AyLRXp2OLNWSvzRlcFxy2qcwU2vIrUSEbiptyOUSbx/e7unIUzj6SzhS6zNzmzzdSfl8 /fxz/CTf2X6lg/VD4INOLMq73S3JLzaBZjd2H47e8OgO8rNWPH9nCV2ffiDsiBJTnSFa Hh6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xTc3bFuoPofuRsvGftSoMen5rimqO1TbZ2F0a38SQEA=; b=kXE9DDSBYSN6DYTfpFPr5XSM72SK8I+V0CPSqxI/0KNz1QzaCJoRMCKr2qXanWmViN NXWLbjuJm6dZlyMWjAz+5f01qIjE/5hJR009PO7l8amjOrzU3+WJA08r6PdiLQBp7noK Cp56YNBDk7JIkGO5LfCMmiLiCc/CKtfy+XkMPIvAazBrzhsQkGde7VO9eDqQ/VbPwNwp qgPUB0NsWSWQOQ/CVOdtkzchUK5JM6ufd5f9DGjNoGkgh4G1jp3R5HK9eRy9YsTadauA 3ljc4rzRTP2xKZ3NvecFAgRpH9sBfi6agC4pSgA35q1hlFgFUSWFjc95rk0/ty0ljiVO I3WQ== X-Gm-Message-State: ANhLgQ3KZDPOtJTEp0g0rLMJ/z35AGTUCySa9giZH0pTNvYDBsDM5XPR AmPiM2Mc/273zwLLMnTyu838RA== X-Google-Smtp-Source: ADFU+vt+SHSF7HAfxNU44ExzTSM9Anpq3FGUCQ2OhVq398EEknfxtcJq4wAGpkkO84j2w1bh93wPtw== X-Received: by 2002:a0c:c70b:: with SMTP id w11mr13308650qvi.246.1584125085774; Fri, 13 Mar 2020 11:44:45 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y5sm13114645qkb.123.2020.03.13.11.44.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Mar 2020 11:44:44 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id D0B22800C55; Fri, 13 Mar 2020 13:44:42 -0500 (CDT) Date: Fri, 13 Mar 2020 13:44:42 -0500 From: Justin Pryzby To: David Rowley Cc: Laurenz Albe , Tomas Vondra , Amit Kapila , Masahiko Sawada , Darafei =?utf-8?Q?Kom=D1=8Fpa?= Praliaskouski , Andres Freund , pgsql-hackers@lists.postgresql.org, Alvaro Herrera , Michael Banck Subject: Re: Berserk Autovacuum (let's save next Mandrill) Message-ID: <20200313184442.GS29065@telsasoft.com> References: <20200107180524.mqz456t2pmr7crpw@development> <98a1422dece118877ebbdc20cb78209f6d12866e.camel@cybertec.at> <0cd8685047ac86fdf9c5446a24ff3aed8755e290.camel@cybertec.at> <2207744f6cc70813d9000510b6bf03ce85db6675.camel@cybertec.at> <602873766faa0e9200a60dcc26dc10c636761d5d.camel@cybertec.at> <91c110aad4b8653d6433d42fd707bd16074c79a5.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Mar 10, 2020 at 01:53:42PM +1300, David Rowley wrote: > 2. Perhaps the documentation in maintenance.sgml should mention that > the table will be vacuumed with the equivalent of having > vacuum_freeze_min_age = 0, instead of: > > "Such a vacuum will aggressively freeze tuples." > > aggressive is the wrong word here. We call it an aggressive vacuum if > we disable page skipping, not for setting the vacuum_freeze_min_age to > 0. Possible it would be better to run VACUUM *without* freeze_min_age=0 ? (I get confused and have to spend 20min re-reading the vacuum GUC docs every time I deal with this stuff, so maybe I'm off). As I understand, the initial motivation of this patch was to avoid disruptive anti-wraparound vacuums on insert-only table. But if vacuum were triggered at all, it would freeze the oldest tuples, which is all that's needed; especially since fd31cd2651 "Don't vacuum all-frozen pages.", those pages would never need to be vacuumed again. Recently written tuples wouldn't be frozen, which is ok, they're handled next time. Another motivation of the patch is to allow indexonly scan, for which the planner looks at pages' "relallvisible" fraction (and at execution if a page isn't allvisible, visits the heap). Again, that happens if vacuum were run at all. Again, some pages won't be marked allvisible, which is fine, they're handled next time. I think freeze_min_age=0 could negatively affect people who have insert-mostly tables (I'm not concerned, but that includes us). If they consistently hit the autovacuum insert threshold before the cleanup threshold for updated/deleted tuples, any updated/deleted tuples would be frozen, which would be wasteful: |One disadvantage of decreasing vacuum_freeze_min_age is that it might cause |VACUUM to do useless work: freezing a row version is a waste of time if the row |is modified soon thereafter (causing it to acquire a new XID). So the setting |should be large enough that rows are not frozen until they are unlikely to |change any more. So my question is if autovacuum triggered by insert threshold should trigger VACUUM with the same settings as a vacuum due to deleted tuples. I realize the DBA could just configure the thresholds so they'd hit vacuum for cleaning dead tuples, so my suggestion maybe just improves the case with the default settings. It's possible to set the reloption autovacuum_freeze_min_age, which I think supports the idea of running a vacuum normally and letting it (and the DBA) decide what do with existing logic. Also, there was a discussion about index cleanup with the conclusion that it was safer not to skip it, since otherwise indexes might bloat. I think that's right, since vacuum for cleanup is triggered by the number of dead heap tuples. To skip index cleanup, I think you'd want a metric for n_dead_since_index_cleanup. (Or maybe analyze could track dead index tuples and trigger vacuum of each index separately). Having now played with the patch, I'll suggest that 10000000 is too high a threshold. If autovacuum runs without FREEZE, I don't see why it couldn't be much lower (100000?) or use (0.2 * n_ins + 50) like the other autovacuum GUC. -- Justin