Andrew Dunstan <[EMAIL PROTECTED]> 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 used
        explain 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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to