Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 5EA552E008E for ; Tue, 29 Jan 2008 10:02:33 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 68176-06 for ; Tue, 29 Jan 2008 10:02:19 -0400 (AST) Received: from host.newx.com.br (host.newx.com.br [216.40.252.42]) by postgresql.org (Postfix) with ESMTP id 5A2742E0079 for ; Tue, 29 Jan 2008 10:02:24 -0400 (AST) Received: from [143.54.12.45] by host.newx.com.br with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1JJr2X-0001qW-1e; Tue, 29 Jan 2008 12:02:17 -0200 Message-ID: <479F3137.2070708@timbira.com> Date: Tue, 29 Jan 2008 11:59:19 -0200 From: Euler Taveira de Oliveira User-Agent: Thunderbird 2.0.0.9 (X11/20071121) MIME-Version: 1.0 To: mlunnon@rwa-net.co.uk CC: pgsql-performance@postgresql.org, Heikki Linnakangas Subject: Re: Performance problems inside a stored procedure. References: <479DC452.8010400@rwa-net.co.uk> <479DC558.30409@enterprisedb.com> <479DC630.9010707@rwa-net.co.uk> In-Reply-To: <479DC630.9010707@rwa-net.co.uk> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.newx.com.br X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - timbira.com X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/284 X-Sequence-Number: 28523 Matthew Lunnon wrote: > Ahh, sorry, I have been too aggressive with my cutting, I am running > 8.2.6 and the function is below. > > $BODY$ > LANGUAGE 'sql' VOLATILE; ^^^^^^^^^^ I suspect that it's because you're using VOLATILE (so no good optimizations is done); did you try STABLE? Could you show us the EXPLAIN ANALYZE of query and function? -- Euler Taveira de Oliveira http://www.timbira.com/