Re: Tuning queries inside a function

From: Richard Huxton <dev(at)archonet(dot)com>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, pgsql general list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Tuning queries inside a function
Date: 2005-05-03 08:12:50
Message-ID: 42773282.8040507@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Nolan wrote:
>>>Maybe you could return a refcursor pointing to the EXPLAIN ANALYZE of
>>>the query inside the function.
>>
>>The raw materials exist to do this: if you know which elements of a
>>query will be replaced by plpgsql variables, you can duplicate the
>>results via
>>
>> PREPARE foo(...) AS ...
>> EXPLAIN EXECUTE foo(...)
>>
>>Certainly there is a lot more that we can and must do about making
>>it easier to debug and tune plpgsql functions. But you can fix 'em
>>with a little determination even now...
>
>
> If I know which elements of a query will be replaced by variables, I can
> enter the query in psql, which I've done. (I can always output the variables
> to the log from inside the function.)

Be aware that if you're pasting values in the place of the variables
then PG can come up with a different plan.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sean Davis 2005-05-03 09:59:02 Re: scripts in Postgres
Previous Message Rolf stvik 2005-05-03 06:50:00 Re: scripts in Postgres