Postgres索引统计数据 [英] Postgres indexes statistics
问题描述
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屋!