Re: SQL Function Performance

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: SQL Function Performance
Дата
Msg-id 20060213054601.GA19126@winnie.fuhr.org
обсуждение исходный текст
Ответ на SQL Function Performance  ("Adnan DURSUN" <a_dursun@hotmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Markus Schaber
Дата:
Сообщение: Re: 10+hrs vs 15min because of just one index
Следующее
От: PFC
Дата:
Сообщение: Re: 10+hrs vs 15min because of just one index