Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l4q9T-0006mt-Fh for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jan 2021 19:06:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l4q9S-0006Li-3C for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Jan 2021 19:06:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l4q9R-0006La-Ne for pgsql-hackers@lists.postgresql.org; Wed, 27 Jan 2021 19:06:49 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l4q9N-0001Xh-Bl for pgsql-hackers@postgresql.org; Wed, 27 Jan 2021 19:06:48 +0000 Received: by mail-il1-x133.google.com with SMTP id e1so2897907ilu.0 for ; Wed, 27 Jan 2021 11:06:44 -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=0N4LHzZ2wGeHjl4uQFs7tKB5F4a6HgM4sR4UN/OAp3U=; b=y1ehDqUAnFQ1r3Q458p81cq1RPwr+6yhl6awQYD4qNHDqcJn9MzSewtjYUlIfpDI5D 6Q1NsZ0Xm+ZhVKRwiilLb3pKI3C3MDqvljZZgdsDmVcLwC3aD0B6clD9AjuMK0tXHbO0 buzCTDQW/dNr7uTRmBYgRW/EvoH9junXShPzMUGwd+8fkhK6Vu2JTjRpROxIlN8WisZE 6m6HblxGbWNwT628uWGzjQuIk/5qB0b1NidqlQEsvDGgBF/KifInvoIp3557C47d7aSl U/fSYHlM3yBmEsHwPaMvbYiMNkyr3Kqx8JUR4NcA8ffcjBxMFO0ASdNDOnaGdr8fzFue 5xYw== 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=0N4LHzZ2wGeHjl4uQFs7tKB5F4a6HgM4sR4UN/OAp3U=; b=m9vsdxs1skhSBQGcVsllzutCNa4bXoqzShxlHL3vwK9nbyTLNg2JiE9Jywgif2HpGr XYzSTOVPvSk9ZaMAJZN0xF2xpCyBgXbTA1uqKNMuRUZjyaG6CgBU2J91emIUDbRNHKur 8m/bdsY375ThgsBEIie0iOWuW8VQUFxp8P6D8qxW4dkWw95l8evH/NVF/J0EtpXibhxn LXBovZsJHeBhBo3u2JyM0Kr5UiZTPt/E3ub9rlrDvGkGpZ3amatZtK4lhxdeHTEDlTzY eX4vuh6MdL0wtnVpAQjwMmJuItZNYhp34pzvpGSr/3rfwViMCKpHApRjJanfZTe6klIP 0aGQ== X-Gm-Message-State: AOAM531POSqINCKawug53sEVogSS9VEkpxiB9JprIGArZrWug+tU9Bce Iqp3ZEJEzb5nGBIVC5CgRkHTuw== X-Google-Smtp-Source: ABdhPJw81nC7Wess0Eg51PIxTau+3ibfzaWOWjrHfh4Rk44ra5UEusRUTyIfOlfO8dDM1cjEcEvYDQ== X-Received: by 2002:a05:6e02:ef0:: with SMTP id j16mr9816873ilk.54.1611774402182; Wed, 27 Jan 2021 11:06:42 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id w9sm1359895ioj.0.2021.01.27.11.06.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jan 2021 11:06:41 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 6217E8009E1; Wed, 27 Jan 2021 13:06:40 -0600 (CST) Date: Wed, 27 Jan 2021 13:06:40 -0600 From: Justin Pryzby To: "Bossart, Nathan" Cc: Vik Fearing , pgsql-hackers@postgresql.org Subject: Re: Add MAIN_RELATION_CLEANUP and SECONDARY_RELATION_CLEANUP options to VACUUM Message-ID: <20210127190640.GT30745@telsasoft.com> References: <657e9792-29b2-9dda-0ea3-73d8ba28b2ac@2ndquadrant.com> <38EFD769-F653-4D30-9DD6-1A335F4F9232@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <38EFD769-F653-4D30-9DD6-1A335F4F9232@amazon.com> 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, Jan 24, 2020 at 09:24:45PM +0000, Bossart, Nathan wrote: > On 1/21/20, 1:39 PM, "Vik Fearing" wrote: > > On 21/01/2020 22:21, Bossart, Nathan wrote: > >> I've attached a patch for a couple of new options for VACUUM: > >> MAIN_RELATION_CLEANUP and SECONDARY_RELATION_CLEANUP. The motive > >> behind these options is to allow table owners to easily vacuum only > >> the TOAST table or only the main relation. This is especially useful > >> for TOAST tables since roles do not have access to the pg_toast schema > >> by default and some users may find it difficult to discover the name > >> of a relation's TOAST table. > > > > > > Could you explain why one would want to do this? Autovacuum will > > already deal with the tables separately as needed, but I don't see when > > a manual vacuum would want to make this distinction. > > The main use case I'm targeting is when the level of bloat or > transaction ages of a relation and its TOAST table have significantly > diverged. In these scenarios, it could be beneficial to be able to > vacuum just one or the other, especially if the tables are large. This just came up for me: I have a daily maintenance script which pro-actively vacuums tables: freezing historic partitions, vacuuming current tables if the table's relfrozenxid is old, and to encourage indexonly scan. I'm checking the greatest(age(toast,main)) and vacuum the table (and implicitly its toast) whenever either is getting old. But it'd be more ideal if I could independently vacuum the main table if it's old, but not the toast table. -- Justin