X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 492A89DC889 for ; Fri, 20 Jan 2006 15:39:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38326-06 for ; Fri, 20 Jan 2006 15:39:40 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pop.xnet.hr (dns1.xnet.hr [82.193.192.5]) by postgresql.org (Postfix) with ESMTP id 66BFD9DC85B for ; Fri, 20 Jan 2006 15:39:36 -0400 (AST) Received: (qmail 5660 invoked from network); 20 Jan 2006 19:39:48 -0000 Received: by simscan 1.1.0 ppid: 5641, pid: 5642, t: 3.6098s scanners: attach: 1.1.0 clamav: 0.87/m:34/d:1131 spam: 3.1.0 Received: from unknown (HELO ?83.139.74.33?) (83.139.74.33) by pop.xnet.hr with SMTP; 20 Jan 2006 19:39:44 -0000 Message-ID: <43D13C2F.1030203@zg.htnet.hr> Date: Fri, 20 Jan 2006 20:38:23 +0100 From: Rikard Pavelic User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: [PERFORMANCE] Stored Procedures References: <43D130EF.3010205@zg.htnet.hr> <20060120191031.GO20182@pervasive.com> In-Reply-To: <20060120191031.GO20182@pervasive.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.479 X-Spam-Level: X-Archive-Number: 200601/358 X-Sequence-Number: 16836 Jim C. Nasby wrote: > My college professor said it, it must be true! ;P > > The famous joke ;) > My understanding is that in plpgsql, 'bare' queries get prepared and act > like prepared statements. IE: > > SELECT INTO variable > field > FROM table > WHERE condition = true > ; > > Unfortunately I don't know enough about PostgreSQL, but from responses I've been reading I've come to that conclusion. > Ok, so post some numbers then. It might be interesting to look at the > cost of preparing a statement, although AFAIK that does not store the > query plan anywhere. > > In most databases, query planning seems to be a pretty expensive > operation. My experience is that that isn't the case with PostgreSQL. > I didn't think about storing query plan anywhere on the disk, rather keep them in memory pool. It would be great if we had an option to use prepare statement for stored procedure so it would prepare it self the first time it's called and remained prepared until server shutdown or memory pool overflow. This would solve problems with prepare which is per session, so for prepared function to be optimal one must use same connection.