HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

log_min_duration_statement setting is ignored

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
log_min_duration_statementsettingignored

Problem

I am running Postgresql 9.1 on Ubuntu. Exact Postgresql version is 9.1+129ubuntu1 as my package manager shows.

I have 2 databases that are actively in use and they are used from a remote server.

I wish to log queries that have a long execution time. So I set following parameters in /etc/postgresql/9.1/main/postgresql.conf file

log_min_duration_statement = 10000
log_statement = 'mod'


so Postgresql will log queries that takes longer than 10 seconds.

But when I reload the postgres configuration, Postgresql begins to log every query that fits log_statement value. That I set duration to 100 seconds to be sure

log_min_duration_statement = 100000


But Postgresql keep logging every query that fits log_statement value, regardless of log_min_duration_statement value.

Setting log_statement to none seemed to stop logging.

Is there something that I missed about the configuration?

Solution

You were close. Your last idea is actually the way to go:

log_statement = none
log_min_duration_statement = 10000


Then no statement will be logged, except those running longer than 10 seconds - including the query string itself. Logging may have seemed to stop because 10 seconds is a high threshold. I am using 2 seconds normally, but YMMV.

This related answer on SO has more:

  • Cannot get log_min_duration_statement to work

Code Snippets

log_statement = none
log_min_duration_statement = 10000

Context

StackExchange Database Administrators Q#62842, answer score: 29

Revisions (0)

No revisions yet.