Re: profiling PL/pgSQL?

From: <korryd(at)enterprisedb(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: profiling PL/pgSQL?
Date: 2006-11-03 19:40:25
Message-ID: 1162582825.7401.44.camel@sakai.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

> > am Fri, dem 03.11.2006, um 3:12:14 -0800 mailte Drew Wilson folgendes:
> >> I have 700 lines of non-performant pgSQL code that I'd like to
> >> profile to see what's going on.
> >>
> >> What's the best way to profile stored procedures?
> >
> > RAISE NOTICE, you can raise the aktual time within a transaction with
> > timeofday()
>
> Of course you only have very small values of "best" available with
> plpgsql debugging.
>
> There's a GUI debugger from EnterpriseDB I believe, but I've no idea how
> good it is. Any users/company bods care to let us know?

It's an excellent debugger (of course, I'm a bit biased).

We are working on open-sourcing it now - we needed some of the plugin
features in 8.2.

As Jonah pointed out, we also have a PL/pgSQL profiler (already
open-sourced but a bit tricky to build). The profiler tells you how
much CPU time you spent at each line of PL/pgSQL code, how many times
you executed each line of code, and how much I/O was caused by each line
(number of scans, blocks fetched, blocks hit, tuples returned, tuples
fetched, tuples inserted, tuples updated, tuples deleted).

It's been a while since I looked at it, but I seem to remember that it
spits out an XML report that you can coax into a nice HTML page via the
XSLT.

The plugin_profiler needs to be converted over to the plugin
architecture in 8.2, but that's not a lot of work.

-- Korry

--
Korry Douglas korryd(at)enterprisedb(dot)com
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Balazs Nagy 2006-11-05 13:47:31 BUG #2737: hash indexing large table fails, while btree of same index works
Previous Message Kevin Grittner 2006-11-03 19:04:34 EXISTS optimization