pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 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 13:11:09 -0400
Message-ID: <28057.1018631469@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.30.0204121224160.847-100000@peter.localdomain>
References: <Pine.LNX.4.30.0204121224160.847-100000@peter.localdomain>

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
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
some amount of pre-parsing of function text themselves, so that the
caching of query plans in itself gives no advantage to plpgsql for
expressions.)  And of course there are many areas where either Tcl or
Perl will win hands down for functionality, for example pattern match
or text substitution tasks.

AFAIK no one has done any actual comparisons to prove or disprove these
theories, though.  It'd be interesting to code up equivalent functions
in all three PL languages and do some benchmarking.  Any volunteers out
there?

			regards, tom lane



view thread (11+ messages)  latest in thread

Message-ID: <28057.1018631469@sss.pgh.pa.us>
Permalink:  ../28057.1018631469@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28057.1018631469@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter_e@gmx.net, gordonc@adf-serials.com
  Subject: Re: Functions in Postgres
  In-Reply-To: <28057.1018631469@sss.pgh.pa.us>

* 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