X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 0340A9FA5BA for ; Thu, 15 Jun 2006 10:03:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 96043-03 for ; Thu, 15 Jun 2006 10:03:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from zeus.gigaweb.cz (zeus.gigaweb.cz [81.0.236.19]) by postgresql.org (Postfix) with SMTP id 0B5219F9CAA for ; Thu, 15 Jun 2006 10:03:31 -0300 (ADT) Received: (qmail 16212 invoked from network); 15 Jun 2006 13:03:28 -0000 Received: from unknown (HELO ?192.168.1.101?) (89.102.195.181) by 0 with SMTP; 15 Jun 2006 13:03:28 -0000 Message-ID: <44915A9D.6090407@fuzzy.cz> Date: Thu, 15 Jun 2006 15:03:25 +0200 From: Tomas Vondra User-Agent: Mail/News 1.5 (X11/20060424) MIME-Version: 1.0 To: Mindaugas CC: pgsql-performance@postgresql.org Subject: Re: How to analyze function performance References: <016401c69075$8a35e8c0$f20214ac@bite.lt> In-Reply-To: <016401c69075$8a35e8c0$f20214ac@bite.lt> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=windows-1257 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/301 X-Sequence-Number: 19658 It depends what is the purpose of the function. If it's mainly a container for a heap of SQL queries along with some simple IF, ELSE etc. then I use two simple ways to analyze the performance (or lack of performance): 1) I use a lot of debug messages 2) I print out all SQL and the execute EXPLAIN / EXPLAIN ANALYZE on them If the function is mainly a computation of something, it's usually nice to try to use for example C language, as it's much faster than PL/pgSQL for this type of functions. But it depends on what you are trying to do in that function ... Tomas > Hello, > > Is it possible to somehow analyze function performance? E.g. > we are using function cleanup() which takes obviously too much time > to execute but I have problems trying to figure what is slowing things > down. > > When I explain analyze function lines step by step it show quite > acceptable performance. > > PostgreSQL 8.0 is running on two dual core Opterons. > > Thanks, > > Mindaugas