【发布时间】:2022-06-29 17:56:41
【问题描述】:
如何在 PostgreSQL 模式 (YugabyteDB) 中收集所有表的统计信息,而无需编写单独的 ANALYZE 命令?
【问题讨论】:
标签: postgresql yugabytedb
如何在 PostgreSQL 模式 (YugabyteDB) 中收集所有表的统计信息,而无需编写单独的 ANALYZE 命令?
【问题讨论】:
标签: postgresql yugabytedb
这将为public 架构中的所有表生成ANALYZE 语句,并使用psql gexec 运行它:
\set ECHO all
select format('analyse %I.%I /* current reltuples: %s */;', nspname, relname, reltuples) ddl
from pg_class natural join (select oid relnamespace, nspname from pg_namespace) s
where relkind = 'r' and nspname='public'
order by reltuples
\gexec
您可以将其更改为另一个架构名称。
在 YugabyteDB 数据库上没有 autovacuum,ANALYZE 仍然是一个 beta 功能(2.15 版)。预计会出现以下警告:
WARNING: 'analyze' is a beta feature!
LINE 1: analyze ehr.access,ehr.attestation,ehr.attestation_ref,ehr.a...
^
HINT: Set 'ysql_beta_features' yb-tserver gflag to true to suppress the warning for all beta features.
在 YugabyteDB 上如果你遇到ERROR: Timed out: Perform RPC (request call id ...) to ... timed out after ...你可能想增加yb_client_admin_operation_timeout_sec
【讨论】: