negimaster
negimaster

Reputation: 97

How do I get query execution duration in postgres logs with a custom log format or in csvlog?

I want to get postgres to log the execution duration of its queries, in either a custom log format or the csvlog format

But I can't find anywhere in the documentation which % tag corresponds to the duration in a custom log format, or which csv column contains the duration.

Where do I find that ?

Upvotes: 0

Views: 1191

Answers (2)

Laurenz Albe
Laurenz Albe

Reputation: 247625

The duration of the statement is not a tag in log_line_prefix. It is part of the log message if you set log_min_duration_statement = 0, which will log all statements and their duration.

Upvotes: 1

NuLo
NuLo

Reputation: 1528

I think you are looking for log duration it is not a % tag as it will be logged in a different line when the query completes. You'll have to make the association between that line and the query using the tags that you logged.

Upvotes: 1

Related Questions