检查PostgreSQL中的统计目标 [英] Check statistics targets in PostgreSQL

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

问题描述

我搜索过,但找不到任何简单,直截了当的答案。如何检查ANALYZE使用的当前统计目标?

I have searched but been unable to find any simple, straight forward answer to this. How do I check the current statistics targets used by ANALYZE?

推荐答案

统计目标的设置按目录中的每列存储表格 pg_attribute 。您可以这样设置:

The setting for the statistics target is stored per column in the catalog table pg_attribute. You can set it like this:

ALTER TABLE myschama.mytable ALTER mycolumn SET STATISTICS 127;

查看如下:

SELECT attstattarget
FROM   pg_attribute
WHERE  attrelid = 'myschama.mytable'::regclass
AND    attname = 'mycolumn';

或者您只需查看pgAdmin的对象浏览器中的创建脚本,如果值与中的默认值不同 default_statistics_target

Or you just look at the creation script in the object browser of pgAdmin, where it is appended if the value is distinct from the default in default_statistics_target.

我在 attstattarget

I quote the manual on attstattarget:


attstattarget控制ANALYZE为此列累积
的统计信息的详细程度。零值表示不收集统计
负值表示使用系统默认
统计目标。
正值的确切含义是数据
类型依赖。对于标量数据类型,attstattarget既是要收集的最常见值的
目标数量,也是要创建的目标
直方图数据块数。

attstattarget controls the level of detail of statistics accumulated for this column by ANALYZE. A zero value indicates that no statistics should be collected. A negative value says to use the system default statistics target. The exact meaning of positive values is data type-dependent. For scalar data types, attstattarget is both the target number of "most common values" to collect, and the target number of histogram bins to create.

强调我的。

这篇关于检查PostgreSQL中的统计目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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