Question

I have a PostgreSQL RDS instance hosted in AWS. I have set the log_min_duration_statement setting to 1 second. When checking my log for slow queries I found the following six entries which don't contain any query/statement:

slow query log

Does anyone have any idea why this happened? How can I find out which slow queries caused these log entries?

UPDATE Thanks to jjanes for pointing me in the right direction. I found that the "log_statement" option causes duration and statement to be logged separately. Here it is in Postgre docs: https://www.postgresql.org/docs/9.1/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT

Was it helpful?

Solution

With log_statements='all', the text of the query is logged when the query begins, and the duration (only) is logged when it ends. You can use the PID or maybe the client IP and port number to pair those up to each other in the log file. I don't know if RDS provides a specific way to do that, I've always done it in 'vim' or 'less'.

But really, I just auto_explain now. I think that this is available in RDS although I've never used it there.

OTHER TIPS

You may have log_duration set to on.
If so, changingit to off should allow you to get statements with your log_min_duration_statement set to 1.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top