pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bossart, Nathan <bossartn@amazon.com>
To: Michael Paquier <michael@paquier.xyz>
To: k.jamison@fujitsu.com <k.jamison@fujitsu.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Add MAIN_RELATION_CLEANUP and SECONDARY_RELATION_CLEANUP options to VACUUM
Date: Wed, 5 Aug 2020 00:56:48 +0000
Message-ID: <FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com> (raw)
In-Reply-To: <20200803064713.GM3317@paquier.xyz>
References: <BA8951E9-1524-48C5-94AF-73B1F0D7857F@amazon.com>
	<20200122050151.GC174860@paquier.xyz>
	<E15A7FC3-1C47-4186-9B5E-C0E407435F90@amazon.com>
	<20200127022850.GB4913@paquier.xyz>
	<1414019F-C6D9-4036-84E2-924051A19E7E@amazon.com>
	<BE2FE6A1-0ACB-4EEF-9B75-072EA03B1F7A@amazon.com>
	<20200713180128.GJ23581@telsasoft.com>
	<B9E127D6-4A52-4E55-B5BF-E68C8D7AD8F1@amazon.com>
	<OSBPR01MB2341077BB2B7FDDEA5CD7D0AEF610@OSBPR01MB2341.jpnprd01.prod.outlook.com>
	<20200803064713.GM3317@paquier.xyz>

On 8/2/20, 11:47 PM, "Michael Paquier" <michael@paquier.xyz> wrote:
> +   VACOPT_TOAST_CLEANUP = 1 << 6,  /* process TOAST table, if any */
> +   VACOPT_DISABLE_PAGE_SKIPPING = 1 << 7,  /* don't skip any pages */
> +   VACOPT_MAIN_REL_CLEANUP = 1 << 8    /* process main relation */
>  } VacuumOption;
>
> Do we actually need this much complication in the option set?  It is
> possible to vacuum directly a toast table by passing directly its
> relation name, with pg_toast as schema, so you can already vacuum a
> toast relation without the main part.  And I would guess that users
> caring about the toast table specifically would know already how to do
> that, even if it requires a simple script and a query on pg_class.
> Now there is a second part, where we'd like to vacuum the main
> relation but not its toast table.  My feeling by looking at this patch
> today is that we could just make VACOPT_SKIPTOAST an option available
> at user-level, and support all the cases discussed on this thread.
> And we have already all the code in place to support that in the
> backend for autovacuum as relations are processed individually,
> without their toast tables if they have one.

My main motive for adding the MAIN_RELATION_CLEANUP option is to allow
table owners to easily vacuum only a relation's TOAST table.  Roles do
not have access to the pg_toast schema by default, so they might be
restricted from vacuuming their TOAST tables directly.

> -static bool vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params);
> +static bool vacuum_rel(Oid relid,
> +                      RangeVar *relation,
> +                      VacuumParams *params,
> +                      bool processing_toast_table);
>
> Not much a fan of the addition of this parameter on this routine to
> track down if the call should process a toast relation or not.
> Couldn't you just prevent the call to vacuum_rel() to happen at all?

I think it would be possible to skip calling vacuum_rel() from
expand_vacuum_rel()/get_all_vacuum_rels() as appropriate, but when I
looked into that approach originally, I was concerned that it would
add complexity to the lookups and ownership checks (especially the
partition lookup logic).  The main tradeoffs of the approach I went
with are that we still create a transaction for the main relation and
that we still lock the main relation.

Nathan



view thread (29+ messages)  latest in thread

Message-ID: <FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com>
Permalink:  ../FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com/
Also on:    postgresql.org/message-id/FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: bossartn@amazon.com, michael@paquier.xyz, k.jamison@fujitsu.com, pryzby@telsasoft.com
  Subject: Re: Add MAIN_RELATION_CLEANUP and SECONDARY_RELATION_CLEANUP options to VACUUM
  In-Reply-To: <FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com>
  References: <BA8951E9-1524-48C5-94AF-73B1F0D7857F@amazon.com> <20200122050151.GC174860@paquier.xyz> <E15A7FC3-1C47-4186-9B5E-C0E407435F90@amazon.com> <20200127022850.GB4913@paquier.xyz> <1414019F-C6D9-4036-84E2-924051A19E7E@amazon.com> <BE2FE6A1-0ACB-4EEF-9B75-072EA03B1F7A@amazon.com> <20200713180128.GJ23581@telsasoft.com> <B9E127D6-4A52-4E55-B5BF-E68C8D7AD8F1@amazon.com> <OSBPR01MB2341077BB2B7FDDEA5CD7D0AEF610@OSBPR01MB2341.jpnprd01.prod.outlook.com> <20200803064713.GM3317@paquier.xyz> <FD08FEE4-CA01-424F-823F-0D7426EDB3D4@amazon.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox