Re: vacuumdb: add --dry-run
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: Corey Huinker <corey.huinker@gmail.com>, Chao Li <li.evan.chao@gmail.com>, pgsql-hackers@postgresql.org
Date: 2025-12-05T20:08:06Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add ParallelSlotSetIdle().
- 750816971b35 19 (unreleased) landed
-
vacuumdb: Add --dry-run.
- d107176d27c7 19 (unreleased) landed
-
vacuumdb: Move some variables to the vacuumingOptions struct.
- cf1450e57799 19 (unreleased) landed
-
Log a note at program start when running in dry-run mode
- c05dee191125 19 (unreleased) cited
On Sat, Dec 06, 2025 at 12:56:22AM +0500, Kirill Reshke wrote:
> Hi!
Thanks for reviewing.
>> + <varlistentry>
>> + <term><option>--dry-run</option></term>
>> + <listitem>
>> + <para>
>> + Print, but do not execute, the vacuum and analyze commands that would
>> + have been sent to the server (performs a dry run).
>> + </para>
>> + </listitem>
>> + </varlistentry>
>
> I compared this smgl section to analogous sections of server utilities
> (pg_dump, pg_resetwal, pg_rewind), none of them mentions "dry run" in
> description of what "--dry run" is. So, I think my feeling is that
> this `(performs a dry run).` is unneeded is correct.
I borrowed this from pg_archivecleanup's documentation. But to your point,
there doesn't seem to be a tremendous amount of consistency in the dry-run
options for various utilities.
>> - printf(_("%s: vacuuming database \"%s\"\n"),
>> - progname, PQdb(conn));
>> + printf(_("%s: vacuuming database \"%s\"%s\n"),
>> + progname, PQdb(conn),
>> + vacopts->dry_run ? " (dry-run)" : "");
>
> I am also not sure we need this change. Look:
>
> ```
> reshke@yezzey-cbdb-bench:~/pg$ ./bin/bin/vacuumdb --dry-run
> vacuumdb: Executing in dry-run mode.
> vacuumdb: vacuuming database "reshke" (dry-run)
> ```
>
> We have two lines which say the same. Well, maybe there is value in
> this change, if we are vacuuming multiple databases, but given that
> --dry-run produces a lot of
> `VACUUM ... -- not executed` output, I think It will be obvious that
> this vacuumdb run does not modify the system. WDYT?
I guess we could probably remove the top-level "Executing in dry-run mode"
message, provided we say the same thing in the per-database message.
However, the latter can be turned off with --quiet. Maybe we should
consider disallowing --quiet and --dry-run.
Overall, I can't claim to have super principled arguments about where I've
added these dry-run messages. I kind-of just sprinkled them around.
--
nathan