PL/PGSQL parameter count vs perfomace

From: Havasvölgyi Ottó <h(dot)otto(at)freemail(dot)hu>
To: <pgsql-general(at)postgresql(dot)org>
Subject: PL/PGSQL parameter count vs perfomace
Date: 2005-08-10 21:33:59
Message-ID: 005401c59df3$3880b520$9a00a8c0@OTTO
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-08-10 21:38:26 Re: 5 new entries for FAQ
Previous Message Martijn van Oosterhout 2005-08-10 21:22:58 Re: 5 new entries for FAQ