PostgreSQL+;分析+;pg_统计表

PostgreSQL+;分析+;pg_统计表,postgresql,Postgresql,我对存储分析数据的PGU统计表有疑问。有人能告诉我这个表的列包含什么吗?我有这个列表,但我不知道(不明白)这一栏里有什么:stanullfrac,stadistinct,stakindN,staopN,stanumbersN,stavaluesN对我来说似乎很简单。特别是,如果您在定义中查看更为用户友好的pg_stat视图(\d+pg_stats) 比如说: select * from pg_statistic where starelid = 23825 and staattnum=2; s

我对存储分析数据的PGU统计表有疑问。有人能告诉我这个表的列包含什么吗?我有这个列表,但我不知道(不明白)这一栏里有什么:
stanullfrac
stadistinct
stakindN
staopN
stanumbersN
stavaluesN
对我来说似乎很简单。特别是,如果您在定义中查看更为用户友好的pg_stat视图(
\d+pg_stats

比如说:

select * from pg_statistic where starelid = 23825 and staattnum=2;

starelid    | 23825      => table (oid)
staattnum   | 2          => column 2
stanullfrac | 0          =>  0% null valuess
stadistinct | -0.484307  => about 48% are distict, i.e., the average repetition is about 2
stakind1    | 1                   => code '1' : most common vals 
stavalues1  | {"John","Mary" ...  => values of most common valss
stanumbers1 | {0.0086,0.0064 ...  => percentage occurrence of common vals
stakind2    | 2                   => code '2' : histogram bounds 
stavalues2  | {-,"AAA", ...       => values (bounds) for histogram intervals
stanumbers2 | 
stakind3    | 3                   => code '3' => correlation
stavalues3  | 
stanumbers3 | {0.00826469}        => correlation coefficient
使用人类可读的
pg\u stats
视图也一样:

select * from pg_stats where tablename = 'persons' and attname = 'first_name';
schemaname        | public
tablename         | persons
attname           | first_name
inherited         | f
null_frac         | 0
avg_width         | 11
n_distinct        | -0.484307
most_common_vals  | {"John","Mary"...
most_common_freqs | {0.00867898,0.00640832...
histogram_bounds  | {-,"AAA"...
correlation       | 0.00826469

大约48%的人是distict,即平均重复次数约为2次这意味着什么?你能告诉我staopN的
栏里有什么吗。下一个问题-有数据类型(及其数量)的列表吗?@KrzysztofTrzos:这只是概率:如果你抛出
D
距离元素,每个元素都有一个平均重复
n
,预期的总数是
T=nD
,因此,
1/n=D/T
(不同元素占总元素的比例).@KrzysztofTrzos:staopN引用pg_operator中定义的运算符。如果你想查看统计数据,我认为这不是很重要,我想它只在优化器内部使用。@KrzysztofTrzos:不同类型的数据不是硬编码的,也就是说,它们可能在pg版本之间有所不同。我猜,参考资料就是来源,例如:见“当前,三个统计时段……”评论和下面的内容。一些推荐阅读:和