pg_stat_user_indexes 是否被复制?

发布于 2025-01-13 13:47:55 字数 344 浏览 6 评论 0原文

我们在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小耗子 2025-01-20 13:47:55

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文