Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 9A9342E00C1 for ; Sat, 23 Feb 2008 14:15:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 41923-08 for ; Sat, 23 Feb 2008 14:14:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id 01FC72E00E7 for ; Sat, 23 Feb 2008 14:14:59 -0400 (AST) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id 94A2C1580333; Sat, 23 Feb 2008 13:18:40 -0500 (EST) Cc: pgsql-jdbc@postgresql.org Message-Id: From: Dave Cramer To: Paul Tomblin In-Reply-To: <47C04916.2070500@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Does "preparing" a PreparedStatement really help? Date: Sat, 23 Feb 2008 13:14:58 -0500 References: <47C04916.2070500@gmail.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/185 X-Sequence-Number: 18392 Depending on the complexity of the statement, yes it does make a difference. You would have to measure it yourself. Your mileage would vary. Dave On 23-Feb-08, at 11:25 AM, Paul Tomblin wrote: > Is there a performance advantage for preparing a PreparedStatement > and keeping it around and using it thousands of times rather than > making a new Statement every time? How big? > > Back when I was doing Oracle Call Interface programming in C back in > the mid to late 1980s, we were always told that pre-parsing a query > was very expensive and so you tried not to do it very often, and > once you'd done it, you stored them to reuse. As I try to switch > this system over to using a connection pool, trying to store > PreparedStatements for each connection is fairly complicated and I'm > wondering if it's worth it. > > > -- > Paul Tomblin http://blog.xcski.com/ > I wouldn't be surprised if I'd have to put garlic in the CD drawer > to really get rid of it. > -- Arthur van der Harg on 'Gator' > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match