vacuumdb/clusterdb/reindexdb: allow specifying objects to process in all databases

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: vacuumdb/clusterdb/reindexdb: allow specifying objects to process in all databases
Date: 2023-06-28 23:24:02
Message-ID: 20230628232402.GA1954626@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

While working on some other patches, I found myself wanting to use the
following command to vacuum the catalogs in all databases in a cluster:

vacuumdb --all --schema pg_catalog

However, this presently fails with the following error:

cannot vacuum specific schema(s) in all databases

AFAICT there no technical reason to block this, and the resulting behavior
feels intuitive to me, so I wrote 0001 to allow it. 0002 allows specifying
tables to process in all databases in clusterdb, and 0003 allows specifying
tables, indexes, schemas, or the system catalogs to process in all
databases in reindexdb.

I debated also allowing users to specify different types of objects in the
same command (e.g., "vacuumdb --schema myschema --table mytable"), but it
looked like this would require a more substantial rewrite, and I didn't
feel that the behavior was intuitive. For the example I just gave, does
the user expect us to process both the "myschema" schema and the "mytable"
table, or does the user want us to process the "mytable" table in the
"myschema" schema? In vacuumdb, this is already blocked, but reindexdb
accepts combinations of tables, schemas, and indexes (yet disallows
specifying --system along with other types of objects). Since this is
inconsistent with vacuumdb and IMO ambiguous, I've restricted such
combinations in 0003.


Nathan Bossart
Amazon Web Services:

Attachment Content-Type Size
v1-0001-vacuumdb-allow-specifying-tables-or-schemas-to-pr.patch text/x-diff 4.5 KB
v1-0002-clusterdb-allow-specifying-tables-to-process-in-a.patch text/x-diff 3.2 KB
v1-0003-reindexdb-allow-specifying-objects-to-process-in-.patch text/x-diff 9.0 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-06-28 23:34:09 Re: Changing types of block and chunk sizes in memory contexts
Previous Message Andres Freund 2023-06-28 22:31:01 Re: Add GUC to tune glibc's malloc implementation.