Обсуждение: How to see detailed plan of a funciton

Поиск
Список
Период
Сортировка

How to see detailed plan of a funciton

От
"Obe, Regina DND\\MIS"
Дата:
I have a pgsql function that returns a set of records and I'm trying to
optimize it.

Needless to say it goes thru several selects and appends to the final
result.  I was wondering how I can see the query plan without having to
write things out piece meal.

Explain doesn't help too much since it doesn't get into the guts of the
selects that the function is doing.

For example my function call looks something like

select * from fnget_near_parcels('17', 'KERR PLACE', '02119')

And if I do an explain on this, I simply get

Function Scan on fnget_near_parcels  (cost=0.00..12.50 rows=1000 width=287)

Thanks,
Regina


-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally  privileged and/or exempt from disclosure pursuant to
Massachusetts law. It is intended  solely for the addressee. If you
received this in error, please contact the sender and  delete the material
from any computer.


Re: How to see detailed plan of a funciton

От
Andreas Seltenreich
Дата:
Regina Obe writes:

> I have a pgsql function that returns a set of records and I'm trying to
> optimize it.
>
> Needless to say it goes thru several selects and appends to the final
> result.  I was wondering how I can see the query plan without having to
> write things out piece meal.

You could enable logging of plans and timings using some GUC
variables:

<http://www.postgresql.org/docs/8.1/static/runtime-config-statistics.html>
<http://www.postgresql.org/docs/8.1/static/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT>

The output is different from explain's, but most of the information
should be there.

regards,
Andreas