Re: [PATCH] pg_dump: Do not dump statistics for excluded tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rian McGuire <rian(dot)mcguire(at)buildkite(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] pg_dump: Do not dump statistics for excluded tables
Date: 2023-12-27 17:01:50
Message-ID: 2588766.1703696510@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rian McGuire <rian(dot)mcguire(at)buildkite(dot)com> writes:
> I've attached a patch against master that addresses a small bug in pg_dump.
> Previously, pg_dump would include CREATE STATISTICS statements for
> tables that were excluded from the dump, causing reload to fail if any
> excluded tables had extended statistics.

I agree that's a bug ...

> The patch skips the creation of the StatsExtInfo if the associated
> table does not have the DUMP_COMPONENT_DEFINITION flag set. This is
> similar to how getPublicationTables behaves if a table is excluded.

... but I don't like the details of this patch (and I'm not too
thrilled with the implementation of getPublicationTables, either).
The style in pg_dump is to put such decisions into separate
policy-setting subroutines. Also, skipping creation of the
DumpableObject altogether is the wrong thing because it'd prevent
pg_dump from tracing or reasoning about dependencies involving the
stats object, which can be relevant even if the object itself isn't
dumped --- this is why all the other data-collection subroutines
operate as they do. getPublicationTables can probably get away
with its low-rent approach given that publication membership isn't
represented by pg_depend entries, but it's far from clear that it'll
never be an issue for stats.

So I think it needs to be more like the attached.
(I did use your test case verbatim.)

regards, tom lane

Attachment Content-Type Size
v2-0001-pg_dump-Do-not-dump-statistics-for-excluded-tables.patch text/x-diff 4.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-12-27 17:38:41 Re: postgres_fdw fails to see that array type belongs to extension
Previous Message jian he 2023-12-27 16:53:13 add function argument names to regex* functions.