Re: Tuning queries inside a function

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

Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Fri, Apr 29, 2005 at 12:32:26PM -0500, Mike Nolan wrote:
>> Any ideas on how to tune a user function?

> 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...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mmiranda 2005-04-30 04:44:53 Re: Fatal error
Previous Message Tom Lane 2005-04-30 03:50:34 Re: the eternal tunnig question