Re: query logging of prepared statements

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: query logging of prepared statements
Date: 2019-04-04 19:01:26
Message-ID: 20190404190126.GA6155@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 2019-Apr-04, Alvaro Herrera wrote:

> I think we could improve on this by setting a "logged" flag in the
> portal; if the Parse logs the statement, then don't include the
> statement in further lines, otherwise do.

Also: I think such a flag could help the case of a query that takes
long enough to execute to exceed the log_min_duration_statement, but not
long enough to parse. Right now, log_min_duration_statement=500 shows

2019-04-04 15:59:39 -03 [6353-1] LOG: duration: 2002.298 ms execute <unnamed>
2019-04-04 15:59:39 -03 [6353-2] DETAIL: parameters: $1 = 'joe''s place'

if I change the testlibpq3 query to be
"SELECT * FROM test1 WHERE t = $1 and pg_sleep(1) is not null",

Also, if you parse once and bind/execute many times, IMO the statement
should be logged exactly once. I think you could that with the flag I
propose.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeremy Schneider 2019-04-04 19:34:04 Re: CVE-2019-9193 about COPY FROM/TO PROGRAM
Previous Message Adrian Klaver 2019-04-04 18:35:58 Re: How serial primary key numbers are assigned

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-04-04 19:04:28 Re: COPY FROM WHEN condition
Previous Message Shawn Debnath 2019-04-04 18:52:52 Re: Retronym: s/magnetic disk/main data/