Re: Performance: sql functions v. plpgsql v. plperl - Mailing list pgsql-general

From Joel Burton
Subject Re: Performance: sql functions v. plpgsql v. plperl
Date
Msg-id Pine.LNX.4.21.0104251656370.15130-100000@olympus.scw.org
Whole thread Raw
In response to Re: Performance: sql functions v. plpgsql v. plperl  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Performance: sql functions v. plpgsql v. plperl
List pgsql-general
On Wed, 25 Apr 2001, Tom Lane wrote:

> Joel Burton <jburton@scw.org> writes:
> > Last night, I was doing some amateurish benchmarking and found that,
> > contrary to my (admittedly uninformed) expectation, sql functions seem
> > *slower* than plsql functions.
>
> IIRC, sql functions are re-parsed/planned on each execution, whereas
> plpgsql functions cache their parse trees and execution plans.
> Depending on exactly what you were doing, that might explain the
> difference.

Why is this?

I'm just delving into the source code in earnest for the first time, so,
forgive any awful errors, but it seems like we have the plumbing for this
in views/rules... couldn't the parse tree be cached from this for each
backend?

Or are SQL functions mildly deprecated since they could always be replaced
by the plpgsql function

begin
  return ...
end;

?


--
Joel Burton   <jburton@scw.org>
Director of Information Systems, Support Center of Washington


pgsql-general by date:

Previous
From: Jan Ploski
Date:
Subject: Re: SUM()ming a view's column
Next
From: Tom Lane
Date:
Subject: Re: Performance: sql functions v. plpgsql v. plperl