postgresql - PostgreSQL 的 pg_stat_all_indexes 表中的统计信息存储多长时间?

标签 postgresql indexing database-indexes database-management

我使用 PostgreSQL 11.1,我正在尝试从 pg_stat_all_indexes 收集信息用于确定是否可以删除特定索引的索引使用表 - 根据 Index size/usage statistics https://wiki.postgresql.org/wiki/Index_Maintenance 中的部分.

我注意到那里的信息随着时间的推移发生了显着变化(从几千个索引命中到 0 个),而且我在文档或此表本身中都找不到有关这些统计数据生命周期的信息。这让我很担心,因为我想确定,我将要做出的关于索引删除的决定是基于足够长一段时间的统计数据。

有没有办法检查这些统计信息在 pg_stat_all_indexes 中存储了多长时间? table ?

最佳答案

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 [...], all statistics counters are reset



(强调我的)

如果要重置统计信息以获得基线,可以使用 pg_stat_reset()然后比较从那时起的值(例如,通过存储每日快照并比较天之间的差异)

关于postgresql - PostgreSQL 的 pg_stat_all_indexes 表中的统计信息存储多长时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59246302/

相关文章:

matlab - 如何高效地垂直合并稀疏矩阵

sql - 是否需要为包含数字的数据库列编制索引?

postgresql - 如何在 PostgresQL 中显示所有无效对象

postgresql - 如何在 PostgreSQL 中为具有 int4range 值的 hstore 类型创建一个运算符

python - 无法在 fedora 27 上从 python3 导入 psycopg2

postgresql - 从游标插入表

mongodb - 为什么索引的方向在 MongoDB 中很重要?

postgresql - Postgres 查询 WHERE 数组

sql - 如何将 DISTINCT 与 string_agg() 和 to_timestamp() 一起使用?

indexing - ArangoDB 3.1 查询解释器