Re: Statistics import and export: difference in statistics of materialized view dumped
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Corey Huinker <corey.huinker@gmail.com>
Date: 2025-03-12T10:59:37Z
Lists: pgsql-hackers
On Wed, Mar 12, 2025 at 4:08 AM Jeff Davis <pgsql@j-davis.com> wrote: > > On Tue, 2025-03-11 at 11:26 -0400, Tom Lane wrote: > > Right, that was what I was thinking, but hadn't had time to look in > > detail. The postDataBound dependency isn't real helpful here, we > > could lose that if we had the data dependency. > > Attached a patch. > > It's a bit messier than I expected, so I'm open to other suggestions. > The reason is because materialized view data is also pushed to > RESTORE_PASS_POST_ACL, so we need to do the same for the statistics > (otherwise the dependency is just ignored). I ran my test with this patch (we have to remove 0003 patch in my test which uses --no-statistics option). It failed with following differences @@ -452068,8 +452068,8 @@ SELECT * FROM pg_catalog.pg_restore_relation_stats( 'version', '180000'::integer, 'relation', 'public.mvtest_aa'::regclass, - 'relpages', '2'::integer, - 'reltuples', '1'::real, + 'relpages', '0'::integer, + 'reltuples', '-1'::real, 'relallvisible', '0'::integer ); -- @@ -452097,8 +452097,8 @@ SELECT * FROM pg_catalog.pg_restore_relation_stats( 'version', '180000'::integer, 'relation', 'public.mvtest_tm_type'::regclass, - 'relpages', '2'::integer, - 'reltuples', '3'::real, + 'relpages', '0'::integer, + 'reltuples', '-1'::real, 'relallvisible', '0'::integer ); -- @@ -452111,8 +452111,8 @@ SELECT * FROM pg_catalog.pg_restore_relation_stats( 'version', '180000'::integer, 'relation', 'public.mvtest_tvmm_expr'::regclass, - 'relpages', '2'::integer, - 'reltuples', '1'::real, + 'relpages', '0'::integer, + 'reltuples', '-1'::real, 'relallvisible', '0'::integer ); --=== stderr === === EOF === The previous differences have disappeared but new differences have appeared. -- Best Wishes, Ashutosh Bapat
Commits
-
Matview statistics depend on matview data.
- a0a4601765b8 18.0 landed