pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Robert Sanford <rsanford@trefs.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Profiling a function...
Date: Fri, 21 Jan 2005 17:20:55 +0000
Message-ID: <41F139F7.6060904@archonet.com> (raw)
In-Reply-To: <8343824939973D4FAC4AD93C1CF35944013A4147@orrtax_exchg3.nls.nlsholdings.com>
References: <8343824939973D4FAC4AD93C1CF35944013A4147@orrtax_exchg3.nls.nlsholdings.com>

Robert Sanford wrote:
> How do I profile a user-defined function so that I know which parts of the
> function are the ones that are taking the biggest chunk of time?
> 
> When I run EXPLAIN on the queries within the function none of them show up
> as onerous burdens to the performance. But when they are all operating
> together within the function and within the functional logic they become
> really expensive. Obviously I've made a mistake somewhere but it isn't
> obvious (otherwise it would be fixed already) and I'd prefer having a
> profile report telling me what is taking so long rather than guessing and
> possibly making things worse.
> 
> So is there any way to get a line-by-line timing profile of a user-defined
> function?

Not really. What you can do is simulate the queries in functions by 
using PREPARE. You're probably seeing a difference because when PG plans 
  the queries for functions/prepared queries it doesn't know the actual 
values.

--
   Richard Huxton
   Archonet Ltd



view thread (2+ messages)

Message-ID: <41F139F7.6060904@archonet.com>
Permalink:  ../41F139F7.6060904@archonet.com/
Also on:    postgresql.org/message-id/41F139F7.6060904@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: dev@archonet.com, rsanford@trefs.com
  Subject: Re: Profiling a function...
  In-Reply-To: <41F139F7.6060904@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox