pg_stat_user_indexes 是否被复制?
我们在 Google Cloud SQL 上运行 Postgres 9.6.23,主实例用于(事务)应用程序,只读副本用于分析目的。
查询 pg_stat_user_indexes 会给出一长串 0 次扫描的结果,但我们不确定如何以足够的信心解释有关副本的这些统计信息,以删除一些索引,因为事务查询和分析查询非常不同。
如何复制 pg_stat_user_indexes
统计信息?
- 即使从副本中读取数据,它们也会相等吗? (即复制的,因此您只能获得主数据库的统计信息)
- 主数据库和副本数据库中的数据可以不同吗? (即不复制,但您需要查询两个实例以检查使用情况)
We are running Postgres 9.6.23 on Google Cloud SQL, with the Primary Instance being used for the (transactional) application and a Read Replica being used for analytical purposes.
Querying pg_stat_user_indexes
gives a long list of results with 0 scans, but we are not sure how to interpret those stats regarding the replicas with enough confidence to drop some of the indexes as the transactional and analytical queries are very different.
How are the pg_stat_user_indexes
stats replicated?
- Will they be equal, even when reading from the replica? (i.e. replicated, so you only get statistics for the primary)
- Can they be different in the primary and replica? (i.e. not replicated, but you need to query both instances to check for usage)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像
pg_stat_user_indexes
这样的统计视图不会显示表中保存的数据,因此不会复制这些数据。相反,当您在备用数据库上查询它们时,它们会显示备用数据库上数据库使用情况的数据。要确定索引是否未使用,请查询主服务器和所有备用服务器上的视图。
Statistics views like
pg_stat_user_indexes
don't show data persisted in tables, so these data are not replicated. Rather, they show data for the database usage on the standby when you query them on a standby.To determine if an index is unused or not, query the view on the primary and all standby servers.