Does anyone know if it's even possible (and how, if yes) to query a database server setting in PostgreSQL (9.1)?
I need to check the max_connections
(maximum number of open db connections) setting.
Can be as simple as:
SHOW max_connections;
This returns the currently effective setting. Be aware that it can differ from the setting in postgresql.conf
as there are a couple of ways to set run-time parameters in PostgreSQL. To reset the "original" setting from postgresql.conf
in your current session:
RESET max_connections;
However, not applicable to this particular setting. Per documentation:
This parameter can only be set at server start.
To see all settings:
SHOW ALL;
More on the SHOW
command in the manual.
If you need more details or want to integrate the look-up into a standard SELECT
query, there is also:
SELECT * FROM pg_settings;
Returns the same result as SHOW ALL
, but with additional information per setting. For your original request:
SELECT *
FROM pg_settings
WHERE name = 'max_connections';
There is also the functional equivalent current_setting(), which can be nested in DML statements.
SELECT current_setting('max_connections');
Related:
来源:https://stackoverflow.com/questions/8288823/query-a-parameter-postgresql-conf-setting-like-max-connections