log_btree_build_stats

用于记录 btree 索引操作统计信息的系统参数

log_btree_build_stats 是一个 配置参数,用于记录各种 btree 操作的系统资源使用统计信息。

log_btree_build_statsPostgreSQL 7.4 中从 show_btree_build_stats 重命名而来。

用法

请注意,仅当在构建 SQL 时定义了宏 BTREE_BUILD_STATS(通常在此处添加:src/include/pg_config_manual.h)时,log_btree_build_stats 才可用。

启用后,PostgreSQL 日志文件将在 LOG 级别包含以 BTREE BUILD ... 开头的条目,以及包含相关统计信息的 DETAIL 输出。示例如下。

默认

log_btree_build_stats 的默认值为:off

变更历史

示例

如果启用了 log_btree_build_stats,当执行 btree 操作时,PostgreSQL 日志文件将包含类似以下的条目:

[2023-12-11 20:06:20 UTC] psql postgres postgres LOG:  00000: statement: CREATE TABLE foo (id INT PRIMARY KEY);
[2023-12-11 20:06:20 UTC] psql postgres postgres LOCATION:  exec_simple_query, postgres.c:1070
[2023-12-11 20:06:20 UTC] psql postgres postgres LOG:  00000: BTREE BUILD (Spool) STATISTICS
[2023-12-11 20:06:20 UTC] psql postgres postgres DETAIL:  ! system usage stats:
        !       0.000072 s user, 0.000013 s system, 0.000083 s elapsed
        !       [0.303226 s user, 0.055857 s system total]
        !       46620 kB max resident size
        !       0/0 [0/44440] filesystem blocks in/out
        !       0/2 [1548/1141] page faults/reclaims, 0 [0] swaps
        !       0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent
        !       0/0 [14/2] voluntary/involuntary context switches
[2023-12-11 20:06:20 UTC] psql postgres postgres LOCATION:  ShowUsage, postgres.c:5071
[2023-12-11 20:06:20 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT PRIMARY KEY);
[2023-12-11 20:06:20 UTC] psql postgres postgres LOG:  00000: BTREE BUILD STATS
[2023-12-11 20:06:20 UTC] psql postgres postgres DETAIL:  ! system usage stats:
        !       0.000151 s user, 0.000028 s system, 0.000180 s elapsed
        !       [0.303438 s user, 0.055896 s system total]
        !       46620 kB max resident size
        !       0/16 [0/44456] filesystem blocks in/out
        !       0/0 [1548/1141] page faults/reclaims, 0 [0] swaps
        !       0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent
        !       0/0 [14/2] voluntary/involuntary context switches
[2023-12-11 20:06:20 UTC] psql postgres postgres LOCATION:  ShowUsage, postgres.c:5071
[2023-12-11 20:06:20 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT PRIMARY KEY);

如果 PostgreSQL 在没有定义 BTREE_BUILD_STATS 的情况下构建,在使用 log_btree_build_stats 和相关命令(如 SHOW)时会引发错误。

postgres=# SHOW log_btree_build_stats;
ERROR:  unrecognized configuration parameter "log_btree_build_stats"

postgres=# SELECT * FROM pg_settings WHERE name = 'log_btree_build_stats';
(0 rows)

分类

开发/测试, GUC 配置项, 索引

反馈

提交对“log_btree_build_stats”的任何评论、建议或更正请在此处进行: 这里