1

I enabled in postgresql.conf this parameters:

log_statement = 'all'
logging_collector = on
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_directory = 'pg_log'

and now I see this:

2020-08-26 11:05:33.151 UTC [29051] postgres@mydb LOG:  duration: 134.300 ms
2020-08-26 11:05:33.475 UTC [29050] postgres@mydb LOG:  duration: 1015.984 ms
2020-08-26 11:05:33.601 UTC [29041] postgres@mydb LOG:  duration: 1149.833 ms
2020-08-26 11:05:34.815 UTC [29053] postgres@mydb LOG:  duration: 2354.413 ms
2020-08-26 11:05:39.963 UTC [29056] postgres@mydb LOG:  duration: 7495.109 ms
2020-08-26 11:05:39.971 UTC [29054] postgres@mydb LOG:  duration: 7506.584 ms
2020-08-26 11:05:39.976 UTC [29055] postgres@mydb LOG:  duration: 7514.726 ms
2020-08-26 11:05:40.101 UTC [29058] postgres@mydb LOG:  duration: 7629.628 ms
2020-08-26 11:05:40.450 UTC [29057] postgres@mydb LOG:  duration: 7973.784 ms
2020-08-26 11:05:41.293 UTC [29059] postgres@mydb LOG:  duration: 8820.805 ms

I want to know which query take so long time.

Postgresql 10 Ubuntu 18.04.2 LTS

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Did you reload the server through a SIGHUP? Changing the log_statement parameter requires this. See the postgres documentation [ServerConfig](https://www.postgresql.org/docs/current/config-setting.html) and [Logging](https://www.postgresql.org/docs/current/runtime-config-logging.html) – D Kramer Aug 26 '20 at 11:37
  • @DKramer , Yes I made the "service postgres restart" and "postgres=# SELECT pg_reload_conf();" – Анар Лятифов Aug 26 '20 at 11:42
  • Other than a potential overwrite of the config file, i'm not sure what the cause is. It seems like the log_statement = 'all' is not being enabled. But as to the reason why, I can't tell. – D Kramer Aug 26 '20 at 11:48

1 Answers1

1

Don't use log_duration and log_statement = 'all'.

Set

log_min_duration_statement = 0

and you have exactly what you want.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263