Re: New GUC to sample log queries

From: Adrien NAYRAT <adrien(dot)nayrat(at)anayrat(dot)info>
To: Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, <alvherre(at)2ndquadrant(dot)com>
Cc: <thomas(dot)munro(at)enterprisedb(dot)com>, <9erthalion6(at)gmail(dot)com>, <tomas(dot)vondra(at)2ndquadrant(dot)com>, <vik(dot)fearing(at)2ndquadrant(dot)com>, <robertmhaas(at)gmail(dot)com>, <michael(at)paquier(dot)xyz>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New GUC to sample log queries
Date: 2018-11-30 08:51:58
Message-ID: 6e498b7e-0e05-8769-6d67-142f6611247d@anayrat.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/30/18 7:42 AM, Nikolay Samokhvalov wrote:
> On Thu, Nov 29, 2018 at 1:49 PM Alvaro Herrera <alvherre(at)2ndquadrant(dot)com
> <mailto:alvherre(at)2ndquadrant(dot)com>> wrote:
>
> Thanks!  I pushed this with two changes -- one was to reword the docs a
> bit more, and the other was to compute in_sample only if it's going to
> be used (when exceeded is true).  I hope this won't upset any
> compilers ...
>
>
> This is a great news – I can imaging how helpful this feature will be
> for query analysis and
> troubleshooting.
>
> At the same time, there is an approach, when we use application (client)
> code or pgbouncer's
> connect_query parameter to perform sampled logging (with
> log_min_duration_statement = 0)
> of n% of all *sessions* or *transactions*.

Good idead! Unfortunately it require pgbouncer, but I keep this trick in
mind.

>
> If you use single-query transactions only, new parameter will do
> equivalent job for you, while
> significantly simplifying you life (pgbouncer is not required and you
> don't need to patch application
> code). However, if you have multi-statement transaction,
> log_statement_sample_rate will not
> be enough for troubleshooting – logging just a single statement of a
> multi-statement transaction
> won't really help to troubleshoot in many cases.
>
> That being said, I wonder, does it make sense to think about extending
> the functionality
> just committed, with some options to to log all statements of n% of
> transactions (or sessions)?
> In other words, allowing to choose, at which level perform sampling –
> statement, transaction, or
> session?
>

+1, I like this idea.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-11-30 08:54:15 Re: [Todo item] Add entry creation timestamp column to pg_stat_replication
Previous Message Adrien NAYRAT 2018-11-30 08:46:57 Re: New GUC to sample log queries