Re: Add SKIP LOCKED to VACUUM and ANALYZE

Nathan Bossart <bossartn@amazon.com>

From: "Bossart, Nathan" <bossartn@amazon.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, "Andres Freund" <andres@anarazel.de>, Masahiko Sawada <sawada.mshk@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Lyes Ameddah <lyes.amd@gmail.com>
Date: 2018-07-24T17:21:25Z
Lists: pgsql-hackers

Attachments

On 7/18/18, 12:00 PM, "Bossart, Nathan" <bossartn@amazon.com> wrote:
> On 7/17/18, 1:22 AM, "Michael Paquier" <michael@paquier.xyz> wrote:
>> The stuff of get_elevel_for_skipped_relation could be refactored into
>> something used as well by cluster_rel as the same logic is used in three
>> places (vacuum_rel, analyze_rel and cluster_rel with try_relation_open).
>
> This seems like a good idea if we intend to add SKIP LOCKED to CLUSTER
> eventually, and it would be nice to cut down on some of the duplicated
> ereport() calls.  I'll look into it.

Here is a patch for refactoring the ereport() calls out of
vacuum_rel() and analyze_rel().  I've kept all four possible log
statements separated for ease of translation.  I considered
simplifying these statements by replacing "vacuum" and "analyze" with
"processing."  However, that seems like it could lead to ambiguity for
commands like "VACUUM (ANALYZE, SKIP_LOCKED) table1 (a);" since both
VACUUM and ANALYZE could be skipped independently.  If we add
SKIP_LOCKED to CLUSTER in the future, we will need to add two more log
statements to this function.

Nathan

Commits

  1. Add option SKIP_LOCKED to VACUUM and ANALYZE

  2. Refactor relation opening for VACUUM and ANALYZE

  3. Refactor cluster_rel() to handle more options

  4. Add assertion in expand_vacuum_rel() for non-autovacuum path