我使用 PostgreSQL 11.1,我正在尝试从 pg_stat_all_indexes
收集信息用于确定是否可以删除特定索引的索引使用表 - 根据 Index size/usage statistics
https://wiki.postgresql.org/wiki/Index_Maintenance 中的部分.
我注意到那里的信息随着时间的推移发生了显着变化(从几千个索引命中到 0 个),而且我在文档或此表本身中都找不到有关这些统计数据生命周期的信息。这让我很担心,因为我想确定,我将要做出的关于索引删除的决定是基于足够长一段时间的统计数据。
有没有办法检查这些统计信息在 pg_stat_all_indexes
中存储了多长时间? table ?
最佳答案
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 [...], all statistics counters are reset
(强调我的)
如果要重置统计信息以获得基线,可以使用 pg_stat_reset()然后比较从那时起的值(例如,通过存储每日快照并比较天之间的差异)
关于postgresql - PostgreSQL 的 pg_stat_all_indexes 表中的统计信息存储多长时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59246302/