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 1jEoKh-0006oM-Gq for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 06:07:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEoKf-0002wt-VF for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 06:07:05 +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 1jEoKf-0002wk-Dp for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2020 06:07:05 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jEoKc-0000AL-6A for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2020 06:07:04 +0000 Received: by mail-qt1-x843.google.com with SMTP id 10so881425qtp.1 for ; Wed, 18 Mar 2020 23:07:01 -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=XAmNheBUtOkGJ9EXe5LsgAFJ5HLrzCR0Zp63M9xIW6k=; b=Ie3zsuVwc6dl8XaFRsq+QI/5p7OMMskxU+2zV7WUr6j/a4UnYIOteuqIet6VmxK7Kk /NZ+09nXv/cL4HsggsplDesWxr+gNi5gR3SrfigkkIPDLd84TiAi2BkDlbICk1WzZC4L W+qor5bBcQG9msL2tzpmXf1b8hXZ7oQTJ0XSS+2yEf0Q106wYhiwH35hsJhH9OTyZVvi SL1k4Wip3hvdvfalMD8VDFzFD1BwIDA34CYUaSy9WH1b7UMWpDNsvvVuUYuNaJ+jnRSh k2Pvtf/uuI8vidNch1DCxO/wiDvEUGEjlscAF9OtJONqEJ1mMdQqvF53e/lemz5iXXVm oboQ== 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=XAmNheBUtOkGJ9EXe5LsgAFJ5HLrzCR0Zp63M9xIW6k=; b=KwaTXGct/1zBidOEzGaPvDiG2qoIc9yy89o/5Ff4ME1MY3dV/qndUYO1aKQQCt642t jsek+8KCr8Wl3T8LBs+DBPK/RlU4k5egTD+uUD7JTMJoF4Nns2eYrSBJZRg7hCZDyWsx AGpqjnVKi3rq+KUp6pKaGLXjBLLbUss5choXwisG3npqJD27Xk9Sisb7Zo2eaf7O2Tv7 +u26P4Tp3iD3LRMscV4b0fzClaLvGcO9FbHg99yUAiYlEG55FM8A35OMRCShFWRwIF3N EBL9TMXSRZg9qV0Tjp8knJP1RPV3Yait0rO4Q6pU6S0dIJetkbs51JPhf+3G9tAtEwmZ KrNA== X-Gm-Message-State: ANhLgQ2zNsldlj80DzBrFJOpECiw3uA9IccvulqVlOncTmEis6z+8Wj8 pM/ENWC9dluka7TvD0RZjckKzQ== X-Google-Smtp-Source: ADFU+vuCyrdGuD5OzbrI76/VAMFzKHnt9BhZYfMwG5HtqAY1hDkZt1h+SVSTGkcAUrEpAA2Mgk1IFg== X-Received: by 2002:aed:2fe7:: with SMTP id m94mr1254189qtd.211.1584598021324; Wed, 18 Mar 2020 23:07:01 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id r192sm907426qke.95.2020.03.18.23.07.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2020 23:07:00 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id DEB14800C55; Thu, 19 Mar 2020 01:06:58 -0500 (CDT) Date: Thu, 19 Mar 2020 01:06:58 -0500 From: Justin Pryzby To: Andres Freund Cc: David Rowley , Laurenz Albe , Tomas Vondra , Amit Kapila , Masahiko Sawada , Darafei =?utf-8?Q?Kom=D1=8Fpa?= Praliaskouski , pgsql-hackers@lists.postgresql.org, Alvaro Herrera , Michael Banck Subject: Re: Berserk Autovacuum (let's save next Mandrill) Message-ID: <20200319060658.GQ26184@telsasoft.com> References: <0cd8685047ac86fdf9c5446a24ff3aed8755e290.camel@cybertec.at> <2207744f6cc70813d9000510b6bf03ce85db6675.camel@cybertec.at> <602873766faa0e9200a60dcc26dc10c636761d5d.camel@cybertec.at> <91c110aad4b8653d6433d42fd707bd16074c79a5.camel@cybertec.at> <20200313184442.GS29065@telsasoft.com> <20200313213851.ejrk5gptnmp65uoo@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200313213851.ejrk5gptnmp65uoo@alap3.anarazel.de> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Mar 13, 2020 at 02:38:51PM -0700, Andres Freund wrote: > On 2020-03-13 13:44:42 -0500, Justin Pryzby wrote: > > 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. > > ISTM that the danger of regressing workloads due to suddenly repeatedly > scanning huge indexes that previously were never / rarely scanned is > significant (if there's a few dead tuples, otherwise most indexes will > be able to skip the scan since the vacuum_cleanup_index_scale_factor > introduction)). We could try to avoid that issue here: | /* If any tuples need to be deleted, perform final vacuum cycle */ | /* XXX put a threshold on min number of tuples here? */ | if (dead_tuples->num_tuples > 0) | { | /* Work on all the indexes, and then the heap */ | lazy_vacuum_all_indexes(onerel, Irel, indstats, vacrelstats, | lps, nindexes); | | /* Remove tuples from heap */ | lazy_vacuum_heap(onerel, vacrelstats); | } As you said, an insert-only table can skip scanning indexes, but an insert-mostly table currently cannot. Maybe we could skip the final index scan if we hit the autovacuum insert threshold? I still don't like mixing the thresholds with the behavior they imply, but maybe what's needed is better docs describing all of vacuum's roles and its procedure and priority in executing them. The dead tuples would just be cleaned up during a future vacuum, right ? So that would be less efficient, but (no surprise) there's a balance to strike and that can be tuned. I think that wouldn't be an issue for most people; the worst case would be if you set high maint_work_mem, and low insert threshold, and you got increased bloat. But faster vacuum if we avoided idx scans. That might allow more flexibility in our discussion around default values for thresholds for insert-triggered vacuum. -- Justin