pg_stat_user_tables.n_mod_since_analyze persistence?

Started by Philip Semanchukabout 5 years ago3 messagesgeneral
Jump to latest
#1Philip Semanchuk
philip@americanefficient.com

Hi all,
I saw some unexpected behavior that I'm trying to understand. I suspect it might be a quirk specific to AWS Aurora and I'd like to confirm that.

When I restart my local Postgres instance (on my Mac), the values in pg_stat_user_tables.n_mod_since_analyze are preserved. In other words, if table foo had n_mod_since_analyze=33 before the reboot, it still has n_mod_since_analyze=33 after the restart.

When I restart an AWS Aurora instance, the values in pg_stat_user_tables.n_mod_since_analyze all seem to be reset to 0.

Can anyone confirm (or refute) that the behavior I see on my Mac (preservation of these values through a restart) is common & expected behavior?

Thanks
Philip

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Philip Semanchuk (#1)
Re: pg_stat_user_tables.n_mod_since_analyze persistence?

Philip Semanchuk <philip@americanefficient.com> writes:

I saw some unexpected behavior that I'm trying to understand. I suspect it might be a quirk specific to AWS Aurora and I'd like to confirm that.

When I restart my local Postgres instance (on my Mac), the values in pg_stat_user_tables.n_mod_since_analyze are preserved. In other words, if table foo had n_mod_since_analyze=33 before the reboot, it still has n_mod_since_analyze=33 after the restart.

When I restart an AWS Aurora instance, the values in pg_stat_user_tables.n_mod_since_analyze all seem to be reset to 0.

Can anyone confirm (or refute) that the behavior I see on my Mac (preservation of these values through a restart) is common & expected behavior?

Yeah, in PG those stats would be preserved, at least as long as it's
a clean shutdown.

regards, tom lane

#3Philip Semanchuk
philip@americanefficient.com
In reply to: Tom Lane (#2)
Re: pg_stat_user_tables.n_mod_since_analyze persistence?

On Feb 15, 2021, at 3:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Philip Semanchuk <philip@americanefficient.com> writes:

I saw some unexpected behavior that I'm trying to understand. I suspect it might be a quirk specific to AWS Aurora and I'd like to confirm that.

When I restart my local Postgres instance (on my Mac), the values in pg_stat_user_tables.n_mod_since_analyze are preserved. In other words, if table foo had n_mod_since_analyze=33 before the reboot, it still has n_mod_since_analyze=33 after the restart.

When I restart an AWS Aurora instance, the values in pg_stat_user_tables.n_mod_since_analyze all seem to be reset to 0.

Can anyone confirm (or refute) that the behavior I see on my Mac (preservation of these values through a restart) is common & expected behavior?

Yeah, in PG those stats would be preserved, at least as long as it's
a clean shutdown.

Thanks, Tom. A colleague pointed me to a blog post by Michael Vitale that confirms this bug on AWS and contains more detail:
https://elephas.io/685-2/

Hope this helps someone else
Philip