If I get it right, settings are hierarchical:
postgres.conf->
postgres.auto.conf (ALTER SYSTEM)->
ALTER DATABASE(where applicable)->
ALTER USER(where applicable)->
SET SESSION(where applicable)->
SET LOCAL(where applicable)
let's say I have enable_seqscan
set to off
at some point. SHOW
or current_setting(
or pg_settings
will show me the current value only. But to check why I have it off, I have to check whole chain. Eg I suspect somebody set it per user or per database, or in auto.conf
- to find how wide the setting is I have to check em all. Otherwise resetting value can fail, eg:
vao=# show enable_seqscan;
enable_seqscan
----------------
off
(1 row)
vao=# set enable_seqscan to default;
SET
vao=# show enable_seqscan;
enable_seqscan
----------------
off
(1 row)
Because it is so for user vao, or for database vao, or deeper...
What is a short way to find the primary source of current value?.. Or preferably matrix of all sources for the setting. Is there any interface or monkey hack?
update to reflect brilliant Abelisto answer:
source, sourcefile from pg_settings
is a wonderful source of information, still I'm asking for a monkey way to check for those reasons: to see the database
or user
in source
I have to relogin - obviously. So before they actually are applied to the session, I can't check them. local and session set shows both SESSION (which kind of reasonable too) and lastly I still have to reset to default step by step all hierarchy. Eg:
vao=# select setting, source, sourcefile from pg_settings where name = 'enable_seqscan';
setting | source | sourcefile
---------+----------+------------
off | database |
(1 row)
vao=# select * from pg_file_settings where name = 'enable_seqscan';
sourcefile | sourceline | seqno | name | setting | applied | error
---------------------------------------------------+------------+-------+----------------+---------+---------+-------
/etc/postgresql/9.6/main/a | 1 | 1 | enable_seqscan | off | f |
/var/lib/postgresql/9.6/main/postgresql.auto.conf | 3 | 26 | enable_seqscan | on | t |
(2 rows)
So If I don't check every source my changes can be not respected.