procedure takes much more time than its query statement

From: Sabin Coanda <s(dot)coanda(at)deuromedia(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: procedure takes much more time than its query statement
Date: 2011-11-01 14:01:03
Message-ID: 864BF5C35722CC4C880BE29B65FD396B4DBB059BEF@exchg1-bv.drm-bv.deuromedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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
query statement, after replacing the arguments with the same values, it
takes just 5 seconds !

I repeat the test several times and the duration is the same.

What is wrong ?

Please note Postgresql version is "PostgreSQL 8.3.5, compiled by Visual C++
build 1400". I used ANALYZE, and my query / function returns about 150 rows.
I made the tests in pgAdmin query windows.

TIA,
Sabin

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Dave Crooke 2011-11-02 01:21:38 Re: procedure takes much more time than its query statement
Previous Message Tom Lane 2011-11-01 13:43:00 Re: Performance Problem with postgresql 9.03, 8GB RAM, Quadcore Processor Server--Need help!!!!!!!