Re: Slow set-returning functions

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Dean Rasheed" <dean_rasheed(at)hotmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow set-returning functions
Date: 2008-01-27 23:01:08
Message-ID: b42b73150801271501p3e47ef8ela42c1ce5bcfac186@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Jan 27, 2008 12:29 PM, Dean Rasheed <dean_rasheed(at)hotmail(dot)com> wrote:
> >> Is there any way that I can see what execution plan is being used
> >> internally by the functions?
> >>
> >
> > Not directly, but you can do this:
> >
> >
> > postgres=# PREPARE p (int4) AS SELECT id FROM foo WHERE lower(name) LIKE
> > 'foo' ORDER BY id OFFSET 0 LIMIT $1;
> > PREPARE
> >
> > postgres=# EXPLAIN EXECUTE p(100); QUERY PLAN
> > -----------------------------------------------------------------------------
> > Limit (cost=0.00..49.18 rows=2 width=4)
> >
> > -> Index Scan using foo_pkey on foo (cost=0.00..614.77 rows=25 width=4)
> > Filter: (lower(name) ~~ 'foo'::text)
> > (3 rows)
>
>
> I think that having the ability to see the execution plans being used
> by queries inside functions would be quite useful.
>
> More generally, I would like to be able to log the execution plans of
> all queries issued by an application (in my case I am working on a web
> application, where some of the queries are auto-generated by
> Hibernate). I've tried setting debug_print_plan, but the results are a
> little hard to interpret.
>
> As an experiment, I have tried hacking around a little with the code.
> This is my first foray into the source code, so I might well be
> missing something, but basically I added a new configuration parameter
> debug_explain_plan which causes all queries to be instrumented and
> ExecutorRun() to call explain_outNode() at the end, logging the
> results at level DEBUG1.

I read your email, blinked twice, and thought: where have you been all
my life! :-)

(IOW, +1)

merlin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Thomas Lozza 2008-01-27 23:01:30 Re: Vacuum and FSM page size
Previous Message Stephen Denne 2008-01-27 21:55:10 Re: 8.3rc1 Out of memory when performing update