Re: SQL Function Performance - Mailing list pgsql-performance

From Michael Fuhr
Subject Re: SQL Function Performance
Date
Msg-id 20060213054601.GA19126@winnie.fuhr.org
Whole thread Raw
In response to SQL Function Performance  ("Adnan DURSUN" <a_dursun@hotmail.com>)
List pgsql-performance
On Sun, Feb 12, 2006 at 10:25:28PM +0200, Adnan DURSUN wrote:
> My database has an SQL function. The result comes in 30-40 seconds
> when i use the SQL function. On the other hand; The result comes
> 300-400 milliseconds when i run the SQL statement. Any idea ??

Have you analyzed the tables?  If that's not the problem then could
you post the EXPLAIN ANALYZE output for the direct query and for a
prepared query?  For the prepared query do this:

PREPARE stmt (varchar, date, int4, varchar, varchar) AS SELECT ... ;

where "..." is the same SQL as in the function body, including the
numbered parameters ($1, $2, etc.).  To execute the query do this:

EXPLAIN ANALYZE EXECUTE stmt (...);

Where "..." is the same parameter list you'd pass to the function
(the same values you used in the direct query).

If you need to re-prepare the query then run "DEALLOCATE stmt"
before doing so.

--
Michael Fuhr

pgsql-performance by date:

Previous
From: Markus Schaber
Date:
Subject: Re: 10+hrs vs 15min because of just one index
Next
From: PFC
Date:
Subject: Re: 10+hrs vs 15min because of just one index