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 1jDwy0-0006Xj-KK for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 21:08:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jDwxz-0005BW-Bl for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2020 21:08:07 +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 1jDwxy-0005BP-Vo for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2020 21:08:07 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jDwxv-0007Ng-ML for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2020 21:08:06 +0000 Received: by mail-qk1-x742.google.com with SMTP id q17so4205156qki.0 for ; Mon, 16 Mar 2020 14:08:03 -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=H91kD9H1WQZLVnePh/ODk71jl3NnC4wfLfN7FE0jjIQ=; b=KEjVnwO5XYRTkKalzuv9IxJzGPwoLn89OtwyE0pAtSbaGwEHOEHWK9HVWCb0Ju7rC8 mo2t0zh06OckXiqfCia/EWC7Nh5u+3cWephOw3/vpBXsy4fqdGCQdnJxSLfoMsdMUeIG uP4dk8W9SbrWyckldUXh0ahLHhP4X9mesIXdiVQDXCv3G99ZfaQqcT1vKjFpklqvy4vF +Kowr6IR7feKQtCI/y2/wXkEKXVKYYxbp+8HltvwCAGfEYTdKEtCqOEJuPhPf0xHjjJP D0BE3GIuYQFkY5K8tXZ5oPmD0YS+qAC+f/+eH8ObzhMVZ4qOx2ITA3+f9KKpb7ePXJlf JPvA== 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=H91kD9H1WQZLVnePh/ODk71jl3NnC4wfLfN7FE0jjIQ=; b=KOEqadwOB8EaEA/riKqSdGjZ/Z/YY8OnvImPajBxLpjrOYleW6Htpv1nP5Nhn91FeY CvEAxFN7Ze04NazVa987AgPxiHxJcpfPlzBmWG9wGpQOlXxHf8WcRfFRfmrqeKayZ5No 2IG/D6V8aTgArrMTa45F/Uw5+eLo9fizGNBv5vRbLchO1YLPlds0X4UQR/h8qpMPv0ON iRD8mloiCsAiMN+TVFWBWvlYXHYh7OD8ia6Nt7Poh6HPBT0nc5KBPS/+FfYZ6arLwOS9 2/x7mnMH9OT/r3GENBJUryQ0xNUOOIiQWKnMHe5GHuWO4ZyB+qKzHFS21vywYnr6ftux IQYw== X-Gm-Message-State: ANhLgQ159lGzCGgkgQMRqK/D2nmKuFf6OluM9mjE8ZoY5zuzsFdLtYCq H2fk/iHIxF/tiDbUv26kEqXf8w== X-Google-Smtp-Source: ADFU+vv5l0C+wAT/i+jSUNPLIYBBCB6YyvBKG8GHKnS9iQw8HxT54Ocg1zXgs1wNUk+fVWlOxNwlQg== X-Received: by 2002:a37:70c1:: with SMTP id l184mr1661621qkc.382.1584392881022; Mon, 16 Mar 2020 14:08:01 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id l6sm654817qti.10.2020.03.16.14.07.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Mar 2020 14:08:00 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 04380800DFD; Mon, 16 Mar 2020 16:07:57 -0500 (CDT) Date: Mon, 16 Mar 2020 16:07:57 -0500 From: Justin Pryzby To: Laurenz Albe Cc: Masahiko Sawada , David Rowley , Tomas Vondra , Amit Kapila , Masahiko Sawada , Darafei =?utf-8?Q?Kom=D1=8Fpa?= Praliaskouski , Andres Freund , PostgreSQL Developers , Alvaro Herrera , Michael Banck Subject: Re: Berserk Autovacuum (let's save next Mandrill) Message-ID: <20200316210757.GO26184@telsasoft.com> References: <9c312999bb8e0495b88d1422980ecc0abc1b1b86.camel@cybertec.at> <20200316124713.GH26184@telsasoft.com> <9c9b7d19d17ad5e4e0ee10b8426fa1b78dd24c0a.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9c9b7d19d17ad5e4e0ee10b8426fa1b78dd24c0a.camel@cybertec.at> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Mar 16, 2020 at 08:49:43PM +0100, Laurenz Albe wrote: > On Mon, 2020-03-16 at 07:47 -0500, Justin Pryzby wrote: > > It seems to me that the easy thing to do is to implement this initially without > > FREEZE (which is controlled by vacuum_freeze_table_age), and defer until > > July/v14 further discussion and implementation of another GUC/relopt for > > autovacuum freezing to be controlled by insert thresholds (or ratio). > > Freezing tuples is the point of this patch. > As I have said, if you have a table where you insert many rows in few > transactions, you would trigger an autovacuum that then ends up doing nothing > because none of the rows have reached vacuum_freeze_table_age yet. > > Then some time later you will get a really large vacuum run. Best practice is to vacuum following bulk load. I don't think this patch is going to change that. Bulk-loaded tuples will be autovacuumed, which is nice, but I don't think it'll be ideal if large bulk loads trigger an autovacuum with cost delays which ISTM if it runs with FREEZE will take even longer. If it's a bulk load, then I think it's okay to assume it was vacuumed, or otherwise that it'll eventually be hit by autovac at some later date. If it's not a "bulk load" but a normal runtime, and the table continues to receive inserts/deletes, then eventually it'll hit a vacuum threshold and tuples can be frozen. If it receives a bunch of activity, which then stops (like a partition of a table of timeseries data), then maybe it doesn't hit a vacuum threshold, until wraparound vacuum. I think in that case it's not catastrophic, since then it wasn't big enough to hit any threshold (it's partitioned). If every day, autovacuum kicks in and does wraparound vacuum on table with data from (say) 100 days ago, I think that's reasonable. One case which would suck is if the insert_threshold were 1e6, and you restore a DB with 1000 tables of historic data (which are no longer being inserted into) which have 9e5 rows each (just below the threshold). Then autovacuum will hit them all at once. The solution to that is to manual vacuum after bulk load, same as today. As a practical matter, some of the tables are likely to hit the autovacuum insert threshold, and some are likely to be pruned (or updated) before wraparound vacuum, so the patch usually does improve that case. -- Justin