C functions quicker than Plpgsql?

Поиск
Список
Период
Сортировка
От Martin Hart
Тема C functions quicker than Plpgsql?
Дата
Msg-id 200311032000.48121.martin@zsdfherg.com
обсуждение исходный текст
Ответы Re: C functions quicker than Plpgsql?
Список pgsql-general
Hi all,

Given a stored procedure that runs entirely within the database (e.g. loop
through a few rows of table A, apply "some function" and create a few rows in
table B) - I am wondering what the performance benefits are of implementing
such a
function in C using the SPI vs plpgsql.

Obviously if "some function" is fairly involved then there may be an
advantage by coding it in C - but if it isn't will the C function
still execute faster?

as an unrealistic simple example...

create function test() returns void as '
declare
 r record;
begin
 for r in select * from table_a where x > 500 loop
  insert into table_b (id) values (a.id);
 end loop;
 return;
end;
' language plpgsql;

now if i write it in C instead, what do i gain performance-wise?

thanks for any light you can shed on this...

Cheers,
Martin


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: question
Следующее
От: "scott.marlowe"
Дата:
Сообщение: Re: Constraint Problem