X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 83C5C9FA60C for ; Wed, 14 Jun 2006 12:16:52 -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 29545-03 for ; Wed, 14 Jun 2006 12:16:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from mail.gmx.net (mail.gmx.de [213.165.64.21]) by postgresql.org (Postfix) with SMTP id B0E309F9CAA for ; Wed, 14 Jun 2006 12:16:42 -0300 (ADT) Received: (qmail invoked by alias); 14 Jun 2006 15:16:40 -0000 Received: from dslb-084-057-019-157.pools.arcor-ip.net (EHLO ltmku) [84.57.19.157] by mail.gmx.net (mp018) with SMTP; 14 Jun 2006 17:16:40 +0200 X-Authenticated: #23352258 From: "Milen Kulev" To: "'Tom Lane'" Cc: Subject: Re: Prepared statements in PGSQL functions Date: Wed, 14 Jun 2006 17:16:39 +0200 Message-ID: <012701c68fc5$895d24f0$0a00a8c0@trivadis.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: <23768.1150295728@sss.pgh.pa.us> X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/159 X-Sequence-Number: 25395 -----Original Message----- From: pgsql-sql-owner@postgresql.org = [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Tom Lane Sent: Wednesday, June 14, 2006 4:35 PM To: Milen Kulev Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Prepared statements in PGSQL functions=20 "Milen Kulev" writes: >> I want to use prepared statement in a function (your comments below). = Wanted just to test the difference ... Why? You seem not to be aware that plpgsql implicitly prepares = statements behind the scenes. &&>> I already have a version with "direct" insert ( just as you say a = couple of lines below) > prepare mystmt( int, int, varchar) as insert into part values = ($1,$2,$3); > execute mystmt(v_id1, v_id2, v_filler ); > deallocate mystmt; If that worked it would be *exactly* the same as just doing insert into part values (v_id1, v_id2, v_filler); except for being slower due to re-preparing each time through the = function. So don't waste your time trying to outsmart the language. >> My idea was to prepare the statment once and execute it in a loop = many times (within a procedure/function). Anyway, obviously there is no performance gain in using prepared statement in = functions. Regards. Milen=20 regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend