PL/PGSQL parameter count vs perfomace - Mailing list pgsql-general

From Havasvölgyi Ottó
Subject PL/PGSQL parameter count vs perfomace
Date
Msg-id 005401c59df3$3880b520$9a00a8c0@OTTO
Whole thread Raw
In response to Change to PostgreSQL  ("Félix Beltrán" <fbeltran@cln.megared.net.mx>)
Responses What's up with EnterpriseDB?
List 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 by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: 5 new entries for FAQ
Next
From: Bruce Momjian
Date:
Subject: Re: 5 new entries for FAQ