↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

支持中的版本: 当前版本 (18) / 17 / 16 / 15 / 14
开发中的版本: 19 / 20devel
已结束支持的版本: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4
历史版本。 PostgreSQL 9.1 已结束支持。 2016-10-27. 请参阅 当前版本手册.

45.62. pg_settings #

视图pg_settings提供对服务器运行时参数的访问。它实质上是SHOW和SET命令的替代接口。它还提供了一些关于每个参数的事实,这些事实无法直接从SHOW中获取,例如最小值和最大值。

表 45.63. pg_settings 列

NameTypeDescription
nametextRun-time configuration parameter name
settingtextCurrent value of the parameter
unittextImplicit unit of the parameter
categorytextLogical group of the parameter
short_desctextA brief description of the parameter
extra_desctextAdditional, more detailed, description of the parameter
contexttextContext required to set the parameter's value (see below)
vartypetextParameter type (bool, enum, integer, real, or string)
sourcetextSource of the current parameter value
min_valtextMinimum allowed value of the parameter (null for non-numeric values)
max_valtextMaximum allowed value of the parameter (null for non-numeric values)
enumvalstext[]Allowed values of an enum parameter (null for non-enum values)
boot_valtextParameter value assumed at server startup if the parameter is not otherwise set
reset_valtextValue that RESET would reset the parameter to in the current session
sourcefiletextConfiguration file the current value was set in (null for values set from sources other than configuration files, or when examined by a non-superuser); helpful when using include directives in configuration files
sourcelineintegerLine number within the configuration file the current value was set at (null for values set from sources other than configuration files, or when examined by a non-superuser)

有几种可能的context值。按照更改设置的难度递减的顺序,它们是:

internal

这些设置不能直接更改;它们反映了内部确定的值。其中一些可能可通过使用不同的配置选项重新构建服务器,或通过更改提供给initdb的选项来进行调整。

postmaster

这些设置只能在服务器启动时应用,因此任何更改都需要重启服务器。这些设置的值通常存储在 postgresql.conf 文件中,或者在服务器启动时通过命令行传递。当然,任何较低 context 类型的设置也都可以在服务器启动时设置。

sighup

可以在 postgresql.conf 中更改这些设置,而无需重启服务器。向 postmaster 发送 SIGHUP 信号,会使其重新读取 postgresql.conf 并应用这些更改。postmaster 还会将 SIGHUP 信号转发给其子进程,以便它们都采用新值。

backend

可以在 postgresql.conf 中更改这些设置,而无需重启服务器。也可以在连接请求报文中为特定会话设置这些值(例如,通过 libpq 的 PGOPTIONS 环境变量);任何用户都可以为其会话进行此类更改。但是,在会话启动后,这些设置永远不会更改。如果在 postgresql.conf 中更改它们,请向 postmaster 发送 SIGHUP 信号,使其重新读取 postgresql.conf。新值只会影响随后启动的会话。

superuser

这些设置可以从postgresql.conf中设置,或者通过SET命令在会话中设置;但只有超级用户可以通过SET更改它们。如果没有使用SET建立会话本地值,那么在postgresql.conf中的更改也会影响到现有会话。

user

这些设置可以从postgresql.conf中设置,或通过SET命令在会话中设置。任何用户都可以更改其会话本地值。如果没有使用SET建立会话本地值,那么在postgresql.conf中的更改也会影响到现有会话。

有关更改这些参数的各种方法,详见第 18.1 节。

pg_settings视图不能插入或删除,但可以更新。对 pg_settings 的某一行执行 UPDATE,等同于对该命名参数执行SET命令。更改只影响当前会话所用的值。如果在之后被中止的事务中发出了 UPDATE,那么事务回滚时 UPDATE 命令的效果也会消失。一旦外围事务提交,这些效果会持续到会话结束,除非被另一个 UPDATE 或 SET 覆盖。

报告文档问题

阅读 上游文档. 反馈更正前请先核对 当前版本手册.