Re: A few new options for vacuumdb

From: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A few new options for vacuumdb
Date: 2019-01-24 00:49:28
Message-ID: 26A57CB3-2847-495F-93CA-9358959CDAD4@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/22/19, 7:41 PM, "Michael Paquier" <michael(at)paquier(dot)xyz> wrote:
> I have been looking at 0002, and I found a problem with the way
> ANALYZE queries are generated. For example take this table:
> CREATE TABLE aa1 (a int);
>
> Then if I try to run ANALYZE with vacuumdb it just works:
> $ vacuumdb -z --table 'aa1(b)'
> vacuumdb: vacuuming database "ioltas"
>
> Note that this fails with HEAD, but passes with your patch. The
> problem is that the query generated misses the lists of columns when
> processing them through split_table_columns_spec(), as what is
> generated is that:
> VACUUM (ANALYZE) public.aa1;
>
> So the result is actually incorrect because all the columns get
> processed.
>
> This patch moves the check about the existence of the relation when
> querying the catalogs, perhaps we would want the same for columns for
> consistency? Or not. That's a bit harder for sure, not impossible
> visibly, still that would mean duplicating a bunch of logic that the
> backend is doing by itself, so we could live without it I think.

Oh, wow. Thanks for pointing this out. I should have caught this.
With 0002, we are basically just throwing out the column lists
entirely as we obtain the qualified identifiers from the catalog
query. To fix this, I've added an optional CTE for tracking any
provided column lists. v5-0001 is your test patch for this case, and
v5-0002 splits out the work for split_table_columns_spec().

Nathan

Attachment Content-Type Size
v5-0001-Add-tests-for-using-vacuumdb-with-column-lists-pr.patch application/octet-stream 1.8 KB
v5-0002-Export-split_table_columns_spec-for-use-in-vacuum.patch application/octet-stream 1.9 KB
v5-0003-Always-use-a-catalog-query-to-discover-tables-to-.patch application/octet-stream 10.2 KB
v5-0004-Add-min-xid-age-and-min-mxid-age-options-to-vacuu.patch application/octet-stream 7.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2019-01-24 00:56:36 Re: Delay locking partitions during INSERT and UPDATE
Previous Message John Naylor 2019-01-24 00:37:56 Re: Delay locking partitions during INSERT and UPDATE