On Thu, Jan 16, 2025 at 4:56 AM Corey Huinker <corey.huin...@gmail.com> wrote:
>>
> Attached is just the pg_dump stuff, and only for relation/attribute stats. 
> The extended stats and vacuumdb work will be in their own threads going 
> forward.

I didn't follow this thread actively,
so if the following issue is already addressed, please forgive me.


pg_dump --dbname=src2 --table=tenk1 --statistics-only --verbose > x.sql
there no pg_restore_attribute_stats, pg_restore_relation_stats there
for table tenk1.
There aren't any statistics, should there be?

also should
pg_dump --dbname=src2 --no-data --no-schema --table=tenk1
dump the statistics? currently seems no.

in doc/src/sgml/ref/pg_dump.sgml
there are six options to control the main output now.
--schema-only, --statistics-only, --data-only,
--no-schema, --no-data, --no-statistics
maybe we need spare one paragraph to explain the default behavior,
and also have an example on it?


pg_dump --dbname=src2 --table=tenk1 --verbose > 1.sql
seems the statistics dump (pg_restore_attribute_stats) is ordered by
attribute name.
should it make more sense to order by attnum?


getRelationStatistics
typedef struct _relStatsInfo
{
    DumpableObject    dobj;
    char            relkind;        /* 'r', 'v', 'c', etc */
    bool            postponed_def;
} RelStatsInfo;
comment /* 'r', 'v', 'c', etc */
Is it wrong?  there is no relkind='c'.
field postponed_def really deserves a comment.


we also need change
enum dbObjectTypePriorities
static const int dbObjectTypePriority[]
?


in dumpRelationStats, we can add Assert on it.
    if (!fout->dopt->dumpStatistics)
        return;
Assert(dobj->dump & DUMP_COMPONENT_STATISTICS);


I found out the owner's info is missing in the dumped content.
for example, the line "Name: STATISTICS DATA tenk1_pkey;" missing owner info.
not sure this is intended?

--
-- Name: tenk1 tenk1_pkey; Type: CONSTRAINT; Schema: public; Owner: jian
--
ALTER TABLE ONLY public.tenk1
    ADD CONSTRAINT tenk1_pkey PRIMARY KEY (unique1);
--
-- Name: STATISTICS DATA tenk1_pkey; Type: STATISTICS DATA; Schema:
public; Owner: -
--
SELECT * FROM pg_catalog.pg_restore_relation_stats(
    'relation', 'public.tenk1_pkey'::regclass,
    'version', '180000'::integer,
    'relpages', '30'::integer,
    'reltuples', '10000'::real,
    'relallvisible', '0'::integer
);


Reply via email to