Re: [PERFORM] procedure takes much more time than its query statement

2011-11-02 Thread Sabin Coanda
Excelent ! You are right Thanks a lot Sabin "Craig Ringer" wrote in message news:4eb0a920.1010...@ringerc.id.au... > On 11/01/2011 10:01 PM, Sabin Coanda wrote: >> Hi there, >> >> I have the function: >> CREATE OR REPLACE FUNCTION "Test"( ... ) >> RETURNS SETOF record AS >> $BODY$ >> BEGIN >>

Re: [PERFORM] procedure takes much more time than its query statement

2011-11-01 Thread Craig Ringer
On 11/01/2011 10:01 PM, Sabin Coanda wrote: Hi there, I have the function: CREATE OR REPLACE FUNCTION "Test"( ... ) RETURNS SETOF record AS $BODY$ BEGIN RETURN QUERY SELECT ...; END; $BODY$ LANGUAGE 'plpgsql' STABLE The function call takes about 5 minute to proceed, but using directly its

Re: [PERFORM] procedure takes much more time than its query statement

2011-11-01 Thread Dave Crooke
The most common reason for this (not specific to PG) is that the function is getting compiled without the substituted constants, and the query plan is generic, whereas with specific values it is able to use column statistics to pick a more efficient one. On Nov 1, 2011 8:16 PM, "Sabin Coanda" wrot