Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 7DF232E33F3 for ; Wed, 9 Jan 2008 16:16:51 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 79779-02-3 for ; Wed, 9 Jan 2008 16:16:43 -0400 (AST) Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 20A652E39EF for ; Wed, 9 Jan 2008 16:16:19 -0400 (AST) Received: (qmail 21253 invoked by uid 1112); 9 Jan 2008 20:16:18 -0000 Date: Wed, 9 Jan 2008 15:16:18 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: mljv@planwerk6.de cc: pgsql-general@postgresql.org Subject: Re: Prepared Statements In-Reply-To: <200801092002.15417.mljv@planwerk6.de> Message-ID: References: <200801092002.15417.mljv@planwerk6.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/402 X-Sequence-Number: 126612 On Wed, 9 Jan 2008, mljv@planwerk6.de wrote: > - I know there is a PREPARE Statement in Postgresql and read the docs. > - in PostgresqlJDBC i have a prepareThreshold parameter which i left to > default of 5. > - in DBCP i have a property "poolPreparedStatements", set to true. Does ist > just configure prepareThreshold of JDBC or does it maintain a statementPool > of it's own? The postgresql JDBC driver does not have a statement pool of its own, so the two options prepareThreshold and poolPreparedStatements are complementary. By itself the JDBC driver will switch to a long term prepared plan once you've used the exact same PreparedStatement object prepareThreshold number of times. Since it doesn't pool things behind the scenes, you've got to retain a reference to the same PreparedStatement object which is difficult or impossible in many applications. This is where the DBCP statement pool comes in. It proxies PreparedStatement wrappers to one underlying PG PreparedStatement object so that you can hit prepareThreshold. > In my Log files of postgresql each query is called like this: > > EXECUTE [PREPARE: select ...] > > I have not found anything about preparing "unnamed" statements. What > does it mean? > Unnamed statements are what the driver uses before it hits the prepareThreshold limit. Once it has determined the statement will be reused many times it changes to a named statement that has a longer lifespan. Kris Jurka