Postgres索引统计数据 [英] Postgres indexes statistics

查看:184
本文介绍了Postgres索引统计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ANALYZE 收集索引统计数据还是只收集表格?

Does ANALYZE collect statistics on indexes or only on tables?

获取数据的正确方法是什么?最新的索引使用情况和统计​​数据?

What is the right way to get the up-to-date indexes usage and statistics?

我的版本是Postgres 9.6

My version is Postgres 9.6

推荐答案

ANALYZE 收集有关表列中值分布的统计信息。

ANALYZE collects statistics on the distribution of the values in table columns.

使用正常索引,您不需要收集索引的任何统计信息,因为您需要知道的是列值的分布。

With a normal index, you don't need to collect any statistics for the index, because all you need to know is the distribution of the column values.

所以如果你没关系 ANALYZE 之前或之后> CREATE INDEX

异常这个规则是表达式的索引。

The exception to this rule are indexes on an expression.

对于这些, ANALYZE 将收集关于<的分布的数据em>表达式的值,所以 ANALYZE 之后CREATE INDEX 将始终改善计划者的估计表达式用于查询中。这是真的,无论索引最终是否在查询执行期间被使用。

For these, ANALYZE will collect data on the distribution of the values of the expression, so ANALYZE after CREATE INDEX will always improve the planner's estimates if that expression is used in a query. This is true, no matter if the index ends up being used during query execution or not.

索引使用情况的统计数据完全不同。您可以在 pg_stat_all_indexes 中找到它们。

Statistics on index usage are a completely different thing. You find them in pg_stat_all_indexes.

这篇关于Postgres索引统计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆