Search Postgresql Archives

stored procedures and dynamic queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux