pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow sampling of statements depending on duration
Date: Wed, 06 Nov 2019 18:11:48 +0000
Message-ID: <E1iSPmW-0007qs-Vz@gemulon.postgresql.org> (raw)

Allow sampling of statements depending on duration

This allows logging a sample of statements, without incurring excessive
log traffic (which may impact performance).  This can be useful when
analyzing workloads with lots of short queries.

The sampling is configured using two new GUC parameters:

 * log_min_duration_sample - minimum required statement duration

 * log_statement_sample_rate - sample rate (0.0 - 1.0)

Only statements with duration exceeding log_min_duration_sample are
considered for sampling. To enable sampling, both those GUCs have to
be set correctly.

The existing log_min_duration_statement GUC has a higher priority, i.e.
statements with duration exceeding log_min_duration_statement will be
always logged, irrespectedly of how the sampling is configured. This
means only configurations

  log_min_duration_sample < log_min_duration_statement

do actually sample the statements, instead of logging everything.

Author: Adrien Nayrat
Reviewed-by: David Rowley, Vik Fearing, Tomas Vondra
Discussion: https://postgr.es/m/bbe0a1a8-a8f7-3be2-155a-888e661cc06c@anayrat.info

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6e3e6cc0e884a6091e1094dff29db430af08fb93

Modified Files
--------------
doc/src/sgml/config.sgml                      | 85 +++++++++++++++++++++++++++
src/backend/tcop/postgres.c                   | 40 +++++++++----
src/backend/utils/misc/guc.c                  | 27 ++++++++-
src/backend/utils/misc/postgresql.conf.sample | 11 ++++
src/include/utils/guc.h                       |  2 +
5 files changed, 153 insertions(+), 12 deletions(-)



Message-ID: <E1iSPmW-0007qs-Vz@gemulon.postgresql.org>
Permalink:  ../E1iSPmW-0007qs-Vz@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iSPmW-0007qs-Vz@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Allow sampling of statements depending on duration
  In-Reply-To: <E1iSPmW-0007qs-Vz@gemulon.postgresql.org>
  References: <E1iSPmW-0007qs-Vz@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox