Home > Net >  How long does pg_statio_all_tables data live for?
How long does pg_statio_all_tables data live for?

Time:08-09

I have read https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STATIO-ALL-TABLES-VIEW

But it does not clarify whether this data is over the whole history of the DB (unless you reset the stats counters). Or whether it is just for recent data.

I am seeing a low cache-hit ratio on one of my tables, but I recently added an index to it. I'm not sure if it is low from all the pre-index usage, or if it is still low, even with the index.

CodePudding user response:

Quote from the manual

When the server shuts down cleanly, a permanent copy of the statistics data is stored in the pg_stat subdirectory, so that statistics can be retained across server restarts. When recovery is performed at server start (e.g., after immediate shutdown, server crash, and point-in-time recovery), all statistics counters are reset.

I read this as "the data is preserved as long as the server is restarted cleanly".

So the data is only reset if recovery was performed or it has been reset manually using pg_stat_reset ().

  • Related