Обсуждение: How to log query parameters instead of variables with log_min_duration_statement

Поиск
Список
Период
Сортировка

How to log query parameters instead of variables with log_min_duration_statement

От
Max Williams
Дата:

Hi,

I am logging long queries with log_min_duration_statement but would like to see the parameters for parameterized queries. Eg…

 

Jun 28 10:21:49 dbs1 postgres[20866]: [2-1] LOG:  duration: 6625.543 ms  execute PRSTMT1405204512-1371060978/PORTAL1405204512-1371060978: SELECT COUNT(*)

Jun 28 10:21:49 dbs1 postgres[20866]: [2-2]        FROM "XYZ123" AS "T0"

Jun 28 10:21:49 dbs1 postgres[20866]: [2-3]        WHERE ("T0"."Id" = $1)

 

I’d like to log or find out what $1 was from the postgresql server side, not the application side. Is this possible?

Best Regards,

Max Williams

Re: How to log query parameters instead of variables with log_min_duration_statement

От
zhong ming wu
Дата:
On Mon, Jun 28, 2010 at 5:29 AM, Max Williams <Max.Williams@mflow.com> wrote:
> Hi,
>
> I am logging long queries with log_min_duration_statement but would like to
> see the parameters for parameterized queries. Eg…
>

Consider increasing log level.  I think you need to go to "debug" at least.

Re: How to log query parameters instead of variables with log_min_duration_statement

От
Tom Lane
Дата:
Max Williams <Max.Williams@mflow.com> writes:
> I am logging long queries with log_min_duration_statement but would like to see the parameters for parameterized
queries.Eg... 

You need a more recent version of Postgres.  The versions that can do
that at all (8.2 and up) will do it automatically.

            regards, tom lane

Re: How to log query parameters instead of variables with log_min_duration_statement

От
Max Williams
Дата:
I'm running 8.4.4 so you are saying this should work?
I don't really want to go to debug level logging, tried it for 5 mins and it just logs too much!

Max

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: 28 June 2010 15:28
To: Max Williams
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] How to log query parameters instead of variables with log_min_duration_statement

Max Williams <Max.Williams@mflow.com> writes:
> I am logging long queries with log_min_duration_statement but would like to see the parameters for parameterized
queries.Eg... 

You need a more recent version of Postgres.  The versions that can do
that at all (8.2 and up) will do it automatically.

            regards, tom lane

Re: How to log query parameters instead of variables with log_min_duration_statement

От
Tom Lane
Дата:
Max Williams <Max.Williams@mflow.com> writes:
> I'm running 8.4.4 so you are saying this should work?

Works for me, just as described here:
http://archives.postgresql.org/pgsql-committers/2006-09/msg00152.php

            regards, tom lane