Re: bug fix and documentation improvement about vacuumdb

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Kuwamura Masaki <kuwamura(at)db(dot)is(dot)i(dot)nagoya-u(dot)ac(dot)jp>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: bug fix and documentation improvement about vacuumdb
Date: 2023-09-14 12:06:51
Message-ID: 9788CCDC-217A-48B0-A0F8-4F311F0F2022@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 14 Sep 2023, at 13:21, Kuwamura Masaki <kuwamura(at)db(dot)is(dot)i(dot)nagoya-u(dot)ac(dot)jp> wrote:

> PATTERN should be changed to SCHEMA because -n and -N options don't support
> pattern matching for schema names. The attached patch 0001 fixes this.

True, there is no pattern matching performed. I wonder if it's worth lifting
the pattern matching from pg_dump into common code such that tools like this
can use it?

> Second, when we use multiple -N options, vacuumdb runs incorrectly as shown below.
> ...

> Even specified by -N, s1.t and s2.t are vacuumed, and also the others are vacuumed
> twice. The attached patch 0002 fixes this.

I can reproduce that, a single -N works but adding multiple -N's makes none of
them excluded. The current coding does this:

if (objfilter & OBJFILTER_SCHEMA_EXCLUDE)
appendPQExpBufferStr(&catalog_query, "OPERATOR(pg_catalog.!=) ");

If the join is instead made to exclude the oids in listed_objects with a left
join and a clause on object_oid being null I can make the current query work
without adding a second clause. I don't have strong feelings wrt if we should
add a NOT IN () or fix this JOIN, but we shouldn't have a faulty join together
with the fix. With your patch the existing join is left in place, let's fix that.

> Third, for the description of the -N option, I wonder if "vacuum all tables except
> in the specified schema(s)" might be clearer. The current one says nothing about
> tables not in the specified schema.

Maybe, but the point of vacuumdb is to analyze a database so I'm not sure who
would expect anything else than vacuuming everything but the excluded schema
when specifying -N. What else could "vacuumdb -N foo" be interpreted to do
that can be confusing?

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2023-09-14 12:55:36 Re: What's the eviction algorithm of newest pg version?
Previous Message Jim Jones 2023-09-14 11:54:24 Re: [PATCH] Add CANONICAL option to xmlserialize