Re: Allow pg_dump --statistics-only to dump foreign table statistics?

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, pgsql-hackers@lists.postgresql.org, pgsql@j-davis.com
Date: 2025-06-16T21:17:26Z
Lists: pgsql-hackers
On Mon, Jun 16, 2025 at 03:39:07PM -0400, Corey Huinker wrote:
> If we aren't exporting stats for foreign tables then that is an oversight,
> the intention always was to fetch all available statistics for all
> relations. I can't offhand think of where we even have the option to
> exclude them.

getRelationStatistics() enumerates the relation kinds:

	if ((relkind == RELKIND_RELATION) ||
		(relkind == RELKIND_PARTITIONED_TABLE) ||
		(relkind == RELKIND_INDEX) ||
		(relkind == RELKIND_PARTITIONED_INDEX) ||
		(relkind == RELKIND_MATVIEW))

The proposed patch [0] adds RELKIND_FOREIGN_TABLE to this list.  That
appears to be the only missing relation kind that ANALYZE handles.

[0] https://postgr.es/m/attachment/177608/v1-0001-pg_dump-Allow-pg_dump-to-dump-the-statistics-for-.patch

-- 
nathan



Commits

  1. pg_dump: Allow pg_dump to dump the statistics for foreign tables.