Re: vacuumdb changes for stats import/export - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: vacuumdb changes for stats import/export
Date
Msg-id Z8oX2u2Db8x2Y1za@nathan
Whole thread Raw
In response to Re: vacuumdb changes for stats import/export  (John Naylor <johncnaylorls@gmail.com>)
List pgsql-hackers
On Thu, Mar 06, 2025 at 06:30:59PM +0700, John Naylor wrote:
> +        This option can only be used in conjunction with
> +        <option>--analyze-only</option> and
> <option>--analyze-in-stages</option>.
> 
> + /* Prohibit --missing-only without --analyze-only or --analyze-in-stages */
> + if (vacopts.missing_only && !vacopts.analyze_only)
> + pg_fatal("cannot use the \"%s\" option without \"%s\" or \"%s\"",
> + "missing-only", "analyze-only", "analyze-in-stages");
> 
> The first is slightly ambiguous, so maybe "or" is better throughout.

Agreed.

> + " CROSS JOIN LATERAL (SELECT c.relkind IN ('p', 'I')) as p (inherited)\n"
> 
> Looking elsewhere in this file, I think we prefer something like
> "(c.relkind OPERATOR(pg_catalog.=) ANY (array["
>   CppAsString2(RELKIND_PARTITIONED_TABLE) ", "
>   CppAsString2(RELKIND_PARTITIONED_INDEX) "]) as p (inherited)\n"

Fixed.

> + " AND NOT EXISTS (SELECT NULL FROM pg_catalog.pg_statistic s\n"
> + " WHERE s.starelid OPERATOR(pg_catalog.=) a.attrelid\n"
> + " AND s.staattnum OPERATOR(pg_catalog.=) a.attnum\n"
> + " AND s.stainherit OPERATOR(pg_catalog.=) p.inherited))\n");
> 
> IIUC correctly, pg_statistic doesn't store stats on itself, so this
> causes the query result to always contain pg_statistic -- does that
> get removed elsewhere?

Good catch.  I think the current behavior is to call ANALYZE on
pg_statistic, too, but that should be mostly harmless (analyze_rel()
refuses to process it).  I suppose we could try to avoid returning
pg_statistic from the catalog query, but we don't bother doing that for any
other vacuumdb modes, so I'm tempted to leave it alone.

-- 
nathan

Attachment

pgsql-hackers by date:

Previous
From: Rafael Thofehrn Castro
Date:
Subject: Re: Proposal: Progressive explain
Next
From: Masahiko Sawada
Date:
Subject: Re: Add contrib/pg_logicalsnapinspect