From: Jan Wieck <janwieck@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Eisentraut <peter_e@gmx.net>
Cc: Gordon Clarke <gordonc@adf-serials.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Functions in Postgres
Date: Fri, 12 Apr 2002 14:16:11 -0400 (EDT)
Message-ID: <200204121816.g3CIGB907316@saturn.janwieck.net> (raw)
In-Reply-To: <28057.1018631469@sss.pgh.pa.us>
Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > Gordon Clarke writes:
> >> I was asking to see if there was any speed penalty with coding a fn in SQL
> >> as opposed to PL/pgsql. It appears that there is and from what you've said
> >> PL/pgsql is slightly faster than PL/TCL and probably PL/Perl. Am I correct
> >> in drawing that conclusion?
>
> > Yes, that seems about right.
>
> plpgsql should be noticeably faster for issuing repetitive SQL queries,
> since it caches query plans and the other two do not. However, I expect
In PL/Tcl, it's the programmer who has to explicitly ask for
query plan caching. It's definitely possible and has been all
the time.
> the reverse is true for simple calculations (arithmetic, text-mashing,
> etc). plpgsql turns *every* expression into an SQL SELECT query; even
> with caching of query plans, I really doubt that our SQL engine can do
> expressions faster than Tcl or Perl can. (Note that both of those do
PL/pgSQL does turn every expression into a SELECT, but then
it analyzes the targetlist a little and if it's just a few
nested function calls with parameters or such, it creates a
suitable executor context and calls ExecEvalExpr() directly,
without going through SPI. Since Tcl's interface is purely
string based, everything goes first from internal to string,
then from string to Tcl's internal and all the way back
again. Not easy to estimate who will win here.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: janwieck@yahoo.com, tgl@sss.pgh.pa.us, peter_e@gmx.net, gordonc@adf-serials.com
Subject: Re: Functions in Postgres
In-Reply-To: <200204121816.g3CIGB907316@saturn.janwieck.net>
* 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