pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Speed up creation of command completion tags
Date: Thu, 15 Dec 2022 21:32:30 +0000
Message-ID: <E1p5vq9-003lnp-CR@gemulon.postgresql.org> (raw)

Speed up creation of command completion tags

The building of command completion tags could often be seen showing up in
profiles when running high tps workloads.

The query completion tags were being built with snprintf, which is slow at
the best of times when compared with more manual ways of formatting
strings.  Here we introduce BuildQueryCompletionString() to do this job
for us.  We also now store the completion tag's strlen in the
CommandTagBehavior struct so that we can quickly memcpy this number of
bytes into the completion tag string.  Appending the rows affected is done
via pg_ulltoa_n.  BuildQueryCompletionString returns the length of the
built string.  This saves us having to call strlen to figure out how many
bytes to pass to pq_putmessage().

Author: David Rowley, Andres Freund
Reviewed-by: Andres Freund
Discussion: https://postgr.es/m/CAHoyFK-Xwqc-iY52shj0G+8K9FJpse+FuZ36XBKy78wDVnd=Qg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ac998020802b742303979a13692afa7b2084d0e9

Modified Files
--------------
src/backend/tcop/cmdtag.c | 72 +++++++++++++++++++++++++++++++++++++++++++++--
src/backend/tcop/dest.c   | 29 +++----------------
src/include/tcop/cmdtag.h |  5 ++++
src/include/tcop/dest.h   |  2 --
4 files changed, 78 insertions(+), 30 deletions(-)



Message-ID: <E1p5vq9-003lnp-CR@gemulon.postgresql.org>
Permalink:  ../E1p5vq9-003lnp-CR@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1p5vq9-003lnp-CR@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: drowley@postgresql.org
  Subject: Re: pgsql: Speed up creation of command completion tags
  In-Reply-To: <E1p5vq9-003lnp-CR@gemulon.postgresql.org>
  References: <E1p5vq9-003lnp-CR@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