pg_clear_attribute_stats()

用于清除属性级别统计信息的函数

pg_clear_attribute_stats() 是一个系统函数,用于清除表中的属性级别统计信息。

pg_clear_attribute_stats()PostgreSQL 18 中添加。

用法

pg_clear_attribute_stats ( relation regclass, attname name, inherited boolean ) → void

pg_clear_attribute_stats() 可以由数据库所有者或拥有 MAINTAIN 权限的角色执行。

变更历史

示例

pg_clear_attribute_stats() 的基本用法示例

postgres=# SELECT tablename, attname, n_distinct
             FROM pg_stats
            WHERE tablename = 'test'
              AND attname = 'id';
 tablename | attname | n_distinct 
-----------+---------+------------
 test      | id      |         42
(1 row)

postgres=# SELECT pg_clear_attribute_stats('test', 'id', false);
 pg_clear_attribute_stats 
--------------------------
 
(1 row)

postgres=# SELECT tablename, attname, n_distinct
             FROM pg_stats
            WHERE tablename = 'test'
              AND attname = 'id';
 tablename | attname | n_distinct 
-----------+---------+------------
(0 rows)

分类

服务器统计信息, 系统函数

另请参阅

pg_restore_attribute_stats(), pg_clear_relation_stats()

反馈

提交任何关于“pg_clear_attribute_stats()”的评论、建议或更正,请点击 此处