Difference between revisions of "Postgresql slow query"

From Origami_Wiki
Jump to navigation Jump to search
(Postgresql slow query)
 
(No difference)

Latest revision as of 11:02, 27 April 2021


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

  1. 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.