From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Speed up plpgsql function startup by doing fewer pallocs.
Date: Wed, 14 Feb 2018 00:10:51 +0000
Message-ID: <E1elkex-0001zE-Gh@gemulon.postgresql.org> (raw)
Speed up plpgsql function startup by doing fewer pallocs.
Previously, copy_plpgsql_datum did a separate palloc for each variable
needing instance-local storage. In simple benchmarks this made for a
noticeable fraction of the total runtime. Improve it by precalculating
the space needed for all of a function's variables and doing just one
palloc for all of them.
In passing, remove PLPGSQL_DTYPE_EXPR from the list of plpgsql "datum"
types, since in fact it has nothing in common with the others, and there
is noplace that needs to discriminate on the basis of dtype between an
expression and any type of datum. And add comments clarifying which
datum struct fields are generic and which aren't.
Tom Lane, reviewed by Pavel Stehule
Discussion: https://postgr.es/m/11986.1514407114@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/40301c1c8bcbe92a9ba9bf017da03e83476ae0e5
Modified Files
--------------
src/pl/plpgsql/src/pl_comp.c | 17 +++++++
src/pl/plpgsql/src/pl_exec.c | 111 ++++++++++++++++++++++++-------------------
src/pl/plpgsql/src/pl_gram.y | 4 --
src/pl/plpgsql/src/plpgsql.h | 84 +++++++++++++++++++-------------
4 files changed, 130 insertions(+), 86 deletions(-)
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: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Speed up plpgsql function startup by doing fewer pallocs.
In-Reply-To: <E1elkex-0001zE-Gh@gemulon.postgresql.org>
References: <E1elkex-0001zE-Gh@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