stored procedures and dynamic queries

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема stored procedures and dynamic queries
Дата
Msg-id 20071203185148.0ee09b31@webthatworks.it
обсуждение исходный текст
Ответы Re: stored procedures and dynamic queries  (Richard Huxton <dev@archonet.com>)
Список 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 по дате отправления:

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: "relation deleted while in use" encountered with Postgresql 8.0.8
Следующее
От: "Josh Harrison"
Дата:
Сообщение: initdb - encoding question