postgresql - 查询一个参数(postgresql.conf 设置)比如 "max_connections"

标签 postgresql configuration settings postgresql-9.1

有谁知道在 PostgreSQL (9.1) 中查询数据库服务器设置是否有可能(以及如何,如果有)?

我需要检查 max_connections(打开的数据库连接的最大数量)设置。

最佳答案

您可以使用 SHOW :

SHOW max_connections;

这将返回当前有效的设置。请注意,它可能与 postgresql.conf 中的设置不同,因为有一个 multiple ways to set run-time parameters in PostgreSQL。 .要在当前 session 中从 postgresql.conf 重置“原始”设置:

RESET max_connections;

但是,不适用于此特定设置。 The manual:

This parameter can only be set at server start.

查看所有设置:

SHOW ALL;

还有pg_settings :

The view pg_settings provides access to run-time parameters of the server. It is essentially an alternative interface to the SHOW and SET commands. It also provides access to some facts about each parameter that are not directly available from SHOW, such as minimum and maximum values.

对于您的原始请求:

SELECT *
FROM   pg_settings
WHERE  name = 'max_connections';

最后,有 current_setting() ,可以嵌套在 DML 语句中:

SELECT current_setting('max_connections');

相关:

关于postgresql - 查询一个参数(postgresql.conf 设置)比如 "max_connections",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8288823/

相关文章:

ruby-on-rails-3 - 在 Rails 3 应用程序中关闭 ip 欺骗检查

Spring 可配置、高性能、计量 http 客户端实例

Django: os.path.join(...) 命令后 BASE_DIR 不正确

c# - XNA/C# 游戏设置(菜单?)

ruby-on-rails - Rails 4 ActiveRecord has_many 通过关系

postgresql - 将 PostgreSQL 配置为仅适用于 LOCALHOST 或指定的 ip + 端口

macos - 如何在不通过 brew 安装的情况下使用 `psql`

asp.net - 默认设置 AutoEventWireup ="false"

internet-explorer - 有没有办法将 Internet Explorer 设置转储到文本文件?

SQL选择连续运行数据的最大值