Обсуждение: pgsql: Speed up creation of command completion tags

Поиск
Список
Период
Сортировка

pgsql: Speed up creation of command completion tags

От
David Rowley
Дата:
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(-)