From: Ian Barwick <ian.barwick@2ndquadrant.com>
To: Ayub M <hiayub@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: postgres stats on the new primary
Date: Tue, 28 Jul 2020 10:53:49 +0900
Message-ID: <94734afa-1110-900e-a8a9-51a1219e14a8@2ndquadrant.com> (raw)
In-Reply-To: <CAOS0qEuCjfRwD2tYQyVg1kQ8EAZQn7ptNnzBwcS2xT_u5S1yOQ@mail.gmail.com>
References: <CAOS0qEuCjfRwD2tYQyVg1kQ8EAZQn7ptNnzBwcS2xT_u5S1yOQ@mail.gmail.com>
On 2020/07/28 9:08, Ayub M wrote:
> I have a RDS PostgreSQL v11.6 with primary and standby. On the primary, vacuum/analyze
> were running and pg_stat_all_tables's last_vacuum/analyze/autovacuum/autoanalyze
> were having values when vacuum/analyze were run.
>
> 1. Switchover to Standby happened, now when I see pg_stat_all_tables (on the active
> primary which was standby earlier), the last vacuum/analyze columns are all nulls.
> Would primary-standby replication not replicate system tables? Is this how it behaves?
The information shown by the various pg_stat_* views is specific to the local
server, and is *not* replicated. In most cases that wouldn't even make
sense. The information is collated by the statistics collector [1] and is stored
in memory and/or files in the data directory, not as a system table.
[1] https://www.postgresql.org/docs/current/monitoring-stats.html
> 2. On the new primary, would the table have stats on them? (I do see pg_stats
> entries for the tables on new standby), are they reliable or do I need to gather
> stats and run vacuum after failover/switchover to standby?
The statistics about the *contents* of the database, as shown by pg_stats, are of
course replicated and will be reliable. More precisely they'll be as up-to-date
as the last vacuum/analyze on the former primary, just you won't see the
information about when that was.
Regards
Ian Barwick
--
Ian Barwick https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ian.barwick@2ndquadrant.com, hiayub@gmail.com
Subject: Re: postgres stats on the new primary
In-Reply-To: <94734afa-1110-900e-a8a9-51a1219e14a8@2ndquadrant.com>
References: <CAOS0qEuCjfRwD2tYQyVg1kQ8EAZQn7ptNnzBwcS2xT_u5S1yOQ@mail.gmail.com> <94734afa-1110-900e-a8a9-51a1219e14a8@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox