Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload PostgreSQL configuration

I am trying to enable the transaction logs in PostgreSQL, where query run time is more than 3 seconds, by setting this flag

log_min_duration_statement = 3000

How to reload the configuration file without restarting the Postgres?

I've tried the below options and got these errors

1) postgres=# select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
LINE 1: select pg_reload_config();
2) postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
like image 214
Suresh Avatar asked Feb 19 '26 04:02

Suresh


2 Answers

1) postgres=# select pg_reload_conf();

2) 
    1) su postgres
    2) /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main reload

Incorrect:

select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
**-->** This is resolved by giving correct function name

postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
**-->** This error is resolved by changing the user to postgres

Thank you @a_horse_with_no_name in helping to identify the typo which causes issue-1

like image 56
Suresh Avatar answered Feb 21 '26 15:02

Suresh


Please use:

SELECT pg_reload_conf();

Or simply:

postgres@server:$ psql -c "SELECT pg_reload_conf()"
like image 26
Alf Normann Klausen Avatar answered Feb 21 '26 14:02

Alf Normann Klausen