PL/PGSQL parameter count vs perfomace

Поиск
Список
Период
Сортировка
От Havasvölgyi Ottó
Тема PL/PGSQL parameter count vs perfomace
Дата
Msg-id 005401c59df3$3880b520$9a00a8c0@OTTO
обсуждение исходный текст
Ответ на Change to PostgreSQL  ("Félix Beltrán" <fbeltran@cln.megared.net.mx>)
Ответы What's up with EnterpriseDB?  (Tony Caduto <tony_caduto@amsoftwaredesign.com>)
Список pgsql-general
Hi,

I would sometimes need a lot of parameters, even 100 or so. These would be
the data access functions for tables. I know the default count limit is 32,
and FUNC_MAX_ARGS compile option should be set to, say, 256.
But I have another option, a bit harder, I could pass the parameters in a
record type. Passing parameters such way is a problematic because the
provider I would use does not support it yet.
My question is that is the second method faster?

Simple example:

create table person(id serial primary key, name text not null, address
text);

--First option:

create function person_ins(_name text, _address text)  --   <<------
returns person
language plpgsql
as
$$
declare
 inserted_row person;
begin
 --insert row
 insert into person (name, address) values (_name, _address);  --  <<-----
 --retrieve inserted row
 select into inserted_row * from person where
id=currval('person_id_seq'::text);
 --return with it
 return inserted_row;
end;
$$;

--Second option:

create function person_ins(_person person)  --    <<----
returns person
language plpgsql
as
$$
declare
 inserted_row person;
begin
 --insert row
 insert into person (name, address) values (_person.name,
person.address);  --   <<------
 --retrieve inserted row
 select into inserted_row * from person where
id=currval('person_id_seq'::text);
 --return with it
 return inserted_row;
end;
$$;


I hope there are no syntax errors.
Of course in a real application I would have a lot more parameters.

Best Regards,
Otto



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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: 5 new entries for FAQ
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: 5 new entries for FAQ