Postgresql slow query
Jump to navigation
Jump to search
1) To enable slow query log in postgresql, firstly you have to open the postgres configuration file "/etc/postgresql/9.1/main/postgresql.conf"
2) Then find the following line
- log_min_duration_statement = -1
Uncomment it and replace -1 with a query runtime threshold in milliseconds.
eg: log_min_duration_statement = 1000
3) Make sure logging_collector is set to on.
4) Then save the configuration and restart the service
sudo systemctl restart postgresql
5) The go to the postgreSQL log collecting directory "/var/lib/pgsql/data/pg_log/" and find the log file in it.