From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Adnan DURSUN <a_dursun(at)hotmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: SQL Function Performance |
Date: | 2006-02-13 05:46:01 |
Message-ID: | 20060213054601.GA19126@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | PFC | 2006-02-13 08:55:20 | Re: 10+hrs vs 15min because of just one index |
Previous Message | andrew | 2006-02-13 01:05:27 | Re: SQL Function Performance |