Re: explain analyze on a function

Поиск
Список
Период
Сортировка
Искать
От
Alvaro Herrera
Тема
Re: explain analyze on a function
Дата
Msg-id
20070614171658.GE27600@alvh.no-ip.org
Ответ на
Список
Дерево обсуждения
explain analyze on a function Rikard Pavelic <rikard.pavelic@zg.htnet.hr>
Re: explain analyze on a function Alvaro Herrera <alvherre@commandprompt.com>
Re: explain analyze on a function Rikard Pavelic <rikard.pavelic@zg.htnet.hr>
Re: explain analyze on a function Alvaro Herrera <alvherre@commandprompt.com>
Re: explain analyze on a function Rikard Pavelic <rikard.pavelic@zg.htnet.hr>
Rikard Pavelic wrote:
> Is this possible?
> 
> I've been searching posts, but to no luck ;(
> 
> I have one SQL query inside function, but when
> i do select from function it takes 8 sec.
> If I execute just SQL query (with some parameters passed to it)
> it takes 0.3 seconds.

Try doing a PREPARE and then EXPLAIN EXECUTE, like

alvherre=# prepare foo as select generate_series(1, $1);
PREPARE

alvherre=# explain analyze execute foo(100);
                                      QUERY PLAN                                      
--------------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.014..0.294 rows=100 loops=1)
 Total runtime: 0.550 ms
(2 filas)

alvherre=# explain analyze execute foo(10000);
                                       QUERY PLAN                                        
-----------------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.012..35.082 rows=10000 loops=1)
 Total runtime: 59.077 ms
(2 filas)


-- 
Alvaro Herrera                               http://www.PlanetPostgreSQL.org/
"La fuerza no está en los medios físicos
sino que reside en una voluntad indomable" (Gandhi)
В списке pgsql-general по дате отправления
От: Gregory Stark
Дата:
Сообщение: Re: DeadLocks..., DeadLocks...
От: Alvaro Herrera
Дата:
Сообщение: Re: DeadLocks..., DeadLocks...
FAQ