pgsql: Speed up creation of command completion tags - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Speed up creation of command completion tags
Date
Msg-id E1p5vq9-003lnp-CR@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Convert range_in and multirange_in to report errors softly.
Next
From: David Rowley
Date:
Subject: pgsql: Re-adjust drop-index-concurrently-1 isolation test