Re: [PERFORM] Performance of SQL Function versus View

2012-04-03 Thread Andrew Dunstan
On 04/03/2012 10:21 AM, Robert Haas wrote: You should probably test this in your environment, but I'd expect the view to be better. Wrapping logic inside PL/pgsql functions needlessly rarely turn outs to be a win. Right, But also note that auto_explain is very useful in getting plans and

Re: [PERFORM] Performance of SQL Function versus View

2012-04-03 Thread Robert Haas
On Wed, Feb 29, 2012 at 3:37 PM, Igor Schtein wrote: > Do you see any performance difference between the following approaches? The > assumption is that most of the rows in the query will be requested often > enough. > > > > 1.   SQL function. > > CREATE OR REPLACE FUNCTION X(IN a_id uuid, IN b

[PERFORM] Performance of SQL Function versus View

2012-02-29 Thread Igor Schtein
Do you see any performance difference between the following approaches? The assumption is that most of the rows in the query will be requested often enough. 1. SQL function. CREATE OR REPLACE FUNCTION X(IN a_id uuid, IN b_id uuid) RETURNS int STABLE AS $$ SELECT count(1) F