Re: Tuning queries inside a function

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

> > 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.) But what I'd rather have is some
way of getting and logging the 'explain' output for a series of function
calls, which I can't seem to achieve inside a function.

I think in the long run I may have to redefine the database to cut back on
the number of queries inside the function.
--
Mike Nolan

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stas Oskin 2005-04-30 23:16:09 Using pgcrypto with AES-256 bits?
Previous Message Raymond O'Donnell 2005-04-30 19:59:53 Re: [ODBC] retrieving images stored by php / pgsql