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 1j9uHt-0001cZ-VS for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2020 17:27:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9uHs-0002vg-FS for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Mar 2020 17:27:56 +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 1j9uHr-0002vZ-Tp for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2020 17:27:56 +0000 Received: from mail-yw1-xc42.google.com ([2607:f8b0:4864:20::c42]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9uHo-00010m-IO for pgsql-hackers@lists.postgresql.org; Thu, 05 Mar 2020 17:27:54 +0000 Received: by mail-yw1-xc42.google.com with SMTP id p69so6336482ywh.10 for ; Thu, 05 Mar 2020 09:27:52 -0800 (PST) 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=IJYD+THN5M2xAiIyfolUC9b+1GbR/PbCq9aANyv8TO8=; b=078MjTfw8DQZ6TX6XltQXXr97eiQn0Wd4f6gZm62uI4QP0im1/AyX5F6DApviHedg+ znuhAmaTl81hmtFInBOwO7KV+9fZ8L1dL1eItLA3K08Bkkoau+UiBdHM2ymBE4Ki2hkz ob1Xlu9SoiPgsTkuRzGC0JCSZwpcfCsvDz8we4kEzucxCNu23Utll29JOdhasb+z/ajt v5hWx0HOlQaLzGhH7tYjCZzzS01LRi/bprXp7S4waQBc6qtx6I42fy4CRUfyYbr07By0 PVwURZf5bTyYYjf28b1ywwrNU6bGhusTDRq8+cEmWXhZ7Euw3tkstHnlHJ7W4Ka3POeA Ne2w== 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=IJYD+THN5M2xAiIyfolUC9b+1GbR/PbCq9aANyv8TO8=; b=tZTQekj5OekWtk7ydcsof+fybTJFUBGsDYQVwtPdbHp8//1uY6aTQOyBsqR2/c4PTu De3NHRhXfkA92IXuCw/xCnEOi7v3SKvXLtI1tCawrfTD9YdJobaVpqnDX3Kfmozuy67n IY0csPy6Xl7CBWQ6oZ+7ytV1LwFYDB1JB3oyj3TE79k92vm0D2QB9Sji5zHyAv7aqNJA Gj8SkL71F1NO2kQMbdf2XU9S1ZccVRywLnKHyUob3NF7u6XYShWgvtJFEEdlre75JLJB /jiYdsPPPWWaPz9XT644inwJ1CqQZEFZEAT+8aMcZlneGPUu4fi+bLmb3hrarURRT8dY T1Gw== X-Gm-Message-State: ANhLgQ39cQkcnybv0O/NSssnqITkp+//6A5sw300LEWC0OM8Hy2N/veu 38MdqYv2dn4BdcRdWG8RZ+1jAQ== X-Google-Smtp-Source: ADFU+vvx43D+tikrKDVyTQ2EcuixSdK9uQiPityq0+jaCR5tMUdvYKhj++1CpBY2lJNNXWgRk2lhBQ== X-Received: by 2002:a0d:ca89:: with SMTP id m131mr7904594ywd.20.1583429271890; Thu, 05 Mar 2020 09:27:51 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e79sm3533054ywe.107.2020.03.05.09.27.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Mar 2020 09:27:51 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id A83D38009F4; Thu, 5 Mar 2020 11:27:49 -0600 (CST) Date: Thu, 5 Mar 2020 11:27:49 -0600 From: Justin Pryzby To: Laurenz Albe Cc: David Rowley , Tomas Vondra , Amit Kapila , Masahiko Sawada , Darafei =?utf-8?Q?Kom=D1=8Fpa?= Praliaskouski , Andres Freund , Alvaro Herrera , Michael Banck , pgsql-hackers@lists.postgresql.org Subject: Re: Berserk Autovacuum (let's save next Mandrill) Message-ID: <20200305172749.GK684@telsasoft.com> References: <20200107180524.mqz456t2pmr7crpw@development> <98a1422dece118877ebbdc20cb78209f6d12866e.camel@cybertec.at> <0cd8685047ac86fdf9c5446a24ff3aed8755e290.camel@cybertec.at> <2207744f6cc70813d9000510b6bf03ce85db6675.camel@cybertec.at> <602873766faa0e9200a60dcc26dc10c636761d5d.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <602873766faa0e9200a60dcc26dc10c636761d5d.camel@cybertec.at> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Mar 05, 2020 at 03:27:31PM +0100, Laurenz Albe wrote: > On Thu, 2020-03-05 at 19:40 +1300, David Rowley wrote: > > 1. I'd go for 2 new GUCs and reloptions. > > autovacuum_vacuum_insert_scale_factor and these should work exactly > > I disagree about the scale_factor (and have not added it to the > updated version of the patch). If we have a scale_factor, then the > time between successive autovacuum runs would increase as the table > gets bigger, which defeats the purpose of reducing the impact of each > autovacuum run. I would vote to include scale factor. You're right that a nonzero scale factor would cause vacuum to run with geometrically decreasing frequency. The same thing currently happens with autoanalyze as a table grows in size. I found that our monthly-partitioned tables were being analyzed too infrequently towards the end of the month. (At the beginning of the month, 10% is 2.4 hours worth of timeseries data, but at the end of the month 10% is 3 days, which was an issue when querying the previous day may have rowcount estimates near zero.) If someone wanted to avoid that, they'd set scale_factor=0. I think this patch should parallel what's already in place, and we can add documention for the behavior if need be. Possibly scale_factor should default to zero, which I think might make sense since insert-only tables seem to be the main target of this patch. > +++ b/doc/src/sgml/maintenance.sgml > + > + Tables that have received more than > + > + inserts since they were last vacuumed and are not eligible for vacuuming > + based on the above criteria will be vacuumed to reduce the impact of a future > + anti-wraparound vacuum run. > + Such a vacuum will aggressively freeze tuples, and it will not clean up dead > + index tuples. "BUT will not clean .." > +++ b/src/backend/postmaster/autovacuum.c > + /* > + * If the number of inserted tuples exceeds the limit I would say "exceeds the threshold" Thanks for working on this; we would use this feature on our insert-only tables. -- Justin