- PostgreSQL 10 Administration Cookbook
- Simon Riggs Gianni Ciolli
- 304字
- 2021-06-25 22:04:05
How to do it…
Your first thought is probably to look in postgresql.conf, which is the configuration file, described in detail in the Updating the parameter file recipe. That works, but only as long as there is only one parameter file. If there are two, then maybe you're reading the wrong file! How would you know? So, the cautious and accurate way is to not trust a text file, but to trust the server itself.
Moreover, you learned in the previous recipe, Changing parameters in your programs, that each parameter has a scope that determines when it can be set. Some parameters can be set through postgresql.conf, but others can be changed afterwards. So, the current values of configuration settings may have been subsequently changed.
We can use the SHOW command like this:
postgres=# SHOW work_mem;
Its output is as follows:
work_mem
----------
1MB
(1 row)
However, remember that it reports the current setting at the time it is run, and that can be changed in many places.
Another way of finding the current settings is to access a PostgreSQL catalog view named pg_settings:
postgres=# \x
Expanded display is on.
postgres=# SELECT * FROM pg_settings WHERE name = 'work_mem';
[ RECORD 1 ] --------------------------------------------------------
name | work_mem
setting | 1024
unit | kB
category | Resource Usage / Memory
short_desc | Sets the maximum memory to be used for query workspaces.
extra_desc | This much memory can be used by each internal sort operation and hash table before switching to temporary disk files.
context | user
vartype | integer
source | default
min_val | 64
max_val | 2147483647
enumvals |
boot_val | 1024
reset_val | 1024
sourcefile |
sourceline |
Thus, you can use the SHOW command to retrieve the value for a setting, or you can access the full details via the catalog table.