Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 3314D2E2E88 for ; Mon, 28 Jan 2008 08:13:40 -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 30367-02-6 for ; Mon, 28 Jan 2008 08:13:29 -0400 (AST) Received: from mail-relay.rwa-net.co.uk (mail-relay.rwa-net.co.uk [62.189.139.18]) by postgresql.org (Postfix) with ESMTP id 2D0AB2E01F1 for ; Mon, 28 Jan 2008 08:10:28 -0400 (AST) Received: from saturn.rwa-net.co.uk (saturn.rwa-net.co.uk [62.189.139.33]) by mail-relay.rwa-net.co.uk (Postfix) with ESMTP id 6719C7D6348 for ; Mon, 28 Jan 2008 11:49:28 +0000 (GMT) Received: from [127.0.0.1] by saturn.rwa-net.co.uk (GMS 14.01.3539/NT4698.00.83343e8d) with ESMTP id sedkgaaa for pgsql-performance@postgresql.org; Mon, 28 Jan 2008 12:10:24 +0000 Message-ID: <479DC630.9010707@rwa-net.co.uk> Date: Mon, 28 Jan 2008 12:10:24 +0000 From: Matthew Lunnon Reply-To: mlunnon@rwa-net.co.uk Organization: RWA User-Agent: Thunderbird 1.5.0.13 (Windows/20070809) MIME-Version: 1.0 To: pgsql-performance@postgresql.org CC: Heikki Linnakangas Subject: Re: Performance problems inside a stored procedure. References: <479DC452.8010400@rwa-net.co.uk> <479DC558.30409@enterprisedb.com> In-Reply-To: <479DC558.30409@enterprisedb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AuthenticatedSender: mlunnon@rwa-net.co.uk X-Info: UNKNOWN-USER X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/262 X-Sequence-Number: 28501 Ahh, sorry, I have been too aggressive with my cutting, I am running 8.2.6 and the function is below. Thanks. Matthew CREATE OR REPLACE FUNCTION sp_get_price_panel_id(int4, "varchar", "varchar", "varchar", bpchar) RETURNS SETOF t_market_price_panel AS $BODY$ SELECT * FROM market mrkt JOIN market_group_relation mgr USING (market_id) JOIN market_group mg USING (market_group_id) JOIN market_group_price_relation mgpr USING (market_group_id) JOIN accommodation_price_panel app ON app.accommodation_price_panel_id = mgpr.price_panel_id WHERE mrkt.live <> 'X'::bpchar AND mg.live <> 'X'::bpchar AND app.live <> 'X'::bpchar AND MARKET_ID = $1 AND CODE = $2 AND CODE_TYPE = $3::CHAR(2) AND CONTRACT_ID = $4 AND ( PRICE_PANEL_TYPE = 'B' OR PRICE_PANEL_TYPE = $5 ); $BODY$ LANGUAGE 'sql' VOLATILE; Heikki Linnakangas wrote: > Matthew Lunnon wrote: >> I have a query which runs pretty quick ( 0.82ms) but when I put it >> inside a stored procedure it takes 10 times as long (11.229ms). Is >> this what you would expect and is there any way that I can get around >> this time delay? > > It depends. You'll need to show us the function. Also, what version of > Postgres are you running? >