CONFIGURATION PARAMETER客户端连接默认值 / 语句行为
client_min_messages
设置发送给客户端的消息级别。
Sets the message levels that are sent to the client.
枚举 会话 引入 9.0(基线) 现存至 20 devel 0 次默认值变更
- 类型
- 枚举enum
- 上下文
- 会话任何用户都可在会话内用 SET 修改
- 默认值
notice- 枚举值
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error- 引入版本
- 9.0(基线)
- 状态
- 现存
版本轨迹
相对 PostgreSQL 17 无变化。
默认值变迁
默认值自 PostgreSQL 9.0 起没有变过。带单位的取值换算成了可读形式,原始的 boot_val 与单位写在悬浮提示里。
手册说明
控制被发送给客户端的消息级别。有效值是DEBUG5、 DEBUG4、DEBUG3、DEBUG2、 DEBUG1、LOG、NOTICE、 WARNING、ERROR。 每个级别都包括其后的所有级别。级别越靠后,被发送的消息越少。默认值是NOTICE。 注意LOG在这里有与log_min_messages中不同的排名。
INFO 级别的消息总是被发送到客户端。
机制详解
client_min_messages:设置发送给客户端的消息级别。该阈值控制返回客户端的消息,而非写入服务器日志的消息;INFO 消息不受此阈值抑制。
client_min_messages 属于 USER 上下文。获授权角色可在会话内修改,ALTER ROLE 或 ALTER DATABASE 可为未来会话建立默认值。
它影响客户端协议中的诊断消息流,而 log_min_messages 与 log_min_error_statement 独立控制服务器端记录;INFO 是始终发送的特殊级别。
调优建议
按典型负载给出的取值思路,不是放之四海皆准的配方:实际取值要看数据量、并发度与硬件。
-
OLTP在线事务处理
按应用诊断契约设置 client_min_messages。保留可操作告警,并按角色或会话调整阈值,而不是让整个集群静音。
-
OLAP分析与批处理
分析与交互用户可能希望看到 NOTICE,但批处理管线应明确选择可解析的消息,避免把通知当作结果行。
-
小规格低配实例与开发机
除非实测客户端消息成为问题,否则保留默认 NOTICE;抑制消息不会显著增加服务器容量。
常见问题
- 只在一个会话中修改 client_min_messages,却认为角色默认值、数据库默认值或其他池化会话也已随之改变。
- 照搬 log_min_messages 的严重级别理解,忽略客户端顺序对 LOG 的处理不同且始终发送 INFO。
- 全局抑制警告,隐藏应用本应展示的弃用信息或运维指引。
- 没有回滚计划及客户端或运维兼容测试,就全局修改 client_min_messages。
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的快照。
-
PostgreSQL 20 ← 19 沿用 19
事实沿用 19
-
PostgreSQL 9.4 ← 9.3 仅描述更新
分类
Reporting and Logging / When to LogClient Connection Defaults / Statement Behavior
逐版本快照
每个收录版本里的 7 项事实,与上一个存在的版本不同的格子带底色。版本号链到该版。
| 版本 | 默认值 | 单位 | 上下文 | 类型 | 最小值 | 最大值 | 枚举值 |
|---|---|---|---|---|---|---|---|
| 9.0 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.1 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.2 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.3 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.4 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.5 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 9.6 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 10 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 11 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 12 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 13 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 14 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 15 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 16 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 17 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 18 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 19 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
| 20 沿用 | notice |
— |
会话 |
枚举 |
— |
— |
debug5, debug4, debug3, debug2, debug1, log, notice, warning, error |
参考资料
同类参数
| 参数 | 类型 | 上下文 | 默认值 | 版本变动 | 最近变更 |
|---|---|---|---|---|---|
| 语句行为 28 | |||||
bytea_output |
枚举 | 会话 | hex |
— | |
| 设置 bytea 的输出格式。 | 现存 | ||||
check_function_bodies |
布尔 | 会话 | on |
— | |
| 在 CREATE FUNCTION 和 CREATE PROCEDURE 时检查例程体。 | 现存 | ||||
client_min_messages |
枚举 | 会话 | notice |
— | |
| 设置发送给客户端的消息级别。 | 现存 | ||||
createrole_self_grant |
字符串 | 会话 | 空字符串 |
— | |
| 设置 CREATEROLE 用户是否将新建角色自动授予自身,以及使用哪些授权选项。 | 现存 | ||||
default_table_access_method |
字符串 | 会话 | heap |
— | |
| 设置新建表默认使用的表访问方法。 | 现存 | ||||
default_tablespace |
字符串 | 会话 | 空字符串 |
— | |
| 设置创建表和索引时使用的默认表空间。 | 现存 | ||||
default_toast_compression |
枚举 | 会话 | pglz |
191 次 | |
| 设置可压缩值默认使用的压缩方法。 | 现存 | ||||
default_transaction_deferrable |
布尔 | 会话 | off |
— | |
| 设置新事务默认是否可延迟。 | 现存 | ||||
default_transaction_isolation |
枚举 | 会话 | read committed |
— | |
| 设置每个新事务的默认隔离级别。 | 现存 | ||||
default_transaction_read_only |
布尔 | 会话 | off |
— | |
| 设置新事务默认是否只读。 | 现存 | ||||
event_triggers |
布尔 | 会话(超级用户) | on |
— | |
| 启用事件触发器。 | 现存 | ||||
gin_pending_list_limit |
整数 | 会话 | 4 MiB |
— | |
| 设置 GIN 索引待处理列表的最大大小。 | 现存 | ||||
idle_in_transaction_session_timeout |
整数 | 会话 | 0 ms |
— | |
| 设置事务内两次查询之间允许空闲的最长时间。 | 现存 | ||||
idle_session_timeout |
整数 | 会话 | 0 ms |
— | |
| 设置不在事务中时两次查询之间允许空闲的最长时间。 | 现存 | ||||
lock_timeout |
整数 | 会话 | 0 ms |
— | |
| 设置每次等待锁所允许的最长时间。 | 现存 | ||||
restrict_nonsystem_relation_kind |
字符串 | 会话 | 空字符串 |
— | |
| 禁止访问指定类别的非系统关系。 | 现存 | ||||
row_security |
布尔 | 会话 | on |
— | |
| 启用行级安全。 | 现存 | ||||
search_path |
字符串 | 会话 | "$user", public |
9.51 次 | |
| 设置解析未限定名称时的模式搜索顺序。 | 现存 | ||||
session_replication_role |
枚举 | 会话(超级用户) | origin |
— | |
| 设置当前会话对触发器和重写规则的处理方式。 | 现存 | ||||
statement_timeout |
整数 | 会话 | 0 ms |
— | |
| 设置单条语句允许执行的最长时间。 | 现存 | ||||
temp_tablespaces |
字符串 | 会话 | 空字符串 |
— | |
| 设置临时表和排序临时文件使用的表空间。 | 现存 | ||||
transaction_deferrable |
布尔 | 会话 | off |
— | |
| 设置当前事务是否可延迟,供只读可串行化事务安全启动。 | 现存 | ||||
transaction_isolation |
枚举 | 会话 | read committed |
122 次 | |
| 设置当前事务的隔离级别。 | 现存 | ||||
transaction_read_only |
布尔 | 会话 | off |
— | |
| 设置当前事务是否只读。 | 现存 | ||||
transaction_timeout |
整数 | 会话 | 0 ms |
— | |
| 设置会话中任一非预备事务允许持续的最长时间。 | 现存 | ||||
vacuum_cleanup_index_scale_factor |
浮点 | 会话 | 0.1 |
— | |
| 设置触发索引清理前允许新增元组数占 reltuples 的比例。 | 于 14 移除 | ||||
xmlbinary |
枚举 | 会话 | base64 |
— | |
| 设置二进制值在 XML 中的编码方式。 | 现存 | ||||
xmloption |
枚举 | 会话 | content |
— | |
| 设置隐式解析和序列化 XML 数据时将其视为文档还是内容片段。 | 现存 | ||||