stored procedures and dynamic queries - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject stored procedures and dynamic queries
Date
Msg-id 20071203185148.0ee09b31@webthatworks.it
Whole thread Raw
Responses Re: stored procedures and dynamic queries
List pgsql-general
Any general rule about dynamically generated queries in stored
procedures vs. performances?

I was going to write stuff as simple as

create or replace function EditQty(int, int, int, varchar(10))
 returns boolean as
'
declare
    _uid alias for $1;
    _aid alias for $2;
    _qty alias for $3;
    _table alias $4;
    _modified timestamp;
begin
    _table := 'shop_commerce_basket' || _table
    _modified := now();
    update _table
    set qty=_qty,
    modified=_modified
    where uid=_uid and aid=_aid;
    if not found then
        insert into _table (uid, aid, qty)
        values(_uid,_aid,_qty);
    end if;
end;
' language plpgsql;

Is it going to perform worse than with a static table name?

Where can I find some clue about the effects of similar decisions?

thx

--
Ivan Sergio Borgonovo
http://www.webthatworks.it


pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: "relation deleted while in use" encountered with Postgresql 8.0.8
Next
From: "Josh Harrison"
Date:
Subject: initdb - encoding question