Re: Error handling in plperl and pltcl - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Error handling in plperl and pltcl
Date
Msg-id 447.1100912825@sss.pgh.pa.us
Whole thread Raw
In response to Re: Error handling in plperl and pltcl  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Error handling in plperl and pltcl  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.net> writes:
> Tom Lane wrote:
>> This will slow down the PL SPI call operations in both languages, but
>> AFAICS it's the only way to provide error handling semantics that aren't
>> too broken for words.

> Can you estimate the extent of the slowdown?

Without actually doing the work, the closest comparison I can make is
between plpgsql functions with and without exception blocks.  I tried

create or replace function foo(int) returns int as '
declare x int;
begin select into x unique1 from tenk1 where unique2 = $1; return x;
end' language plpgsql;

create or replace function foo(int) returns int as '
declare x int;
begin begin   select into x unique1 from tenk1 where unique2 = $1; exception   when others then null; end; return x;
end' language plpgsql;

and usedexplain analyze select foo(unique2) from tenk1;
to execute each one 10000 times without too much overhead.
I get about 6900 vs 12800 msec, so for a simple pre-planned query
it's not quite a 50% overhead.  This is probably about the worst
case you'd see in practice --- unlike plpgsql, plperl and pltcl
functions wouldn't be calling the SQL engine to do simple arithmetic,
so they're not going to have SPI calls that do much less work than
this example does.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Error handling in plperl and pltcl
Next
From: "Barry Lind"
Date:
Subject: Re: [JDBC] Strange server error with current 8.0beta driver