Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 9C0FD2E0091 for ; Sat, 12 Jan 2008 18:04:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 00330-09 for ; Sat, 12 Jan 2008 18:04:43 -0400 (AST) Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 186ED2E02AD for ; Sat, 12 Jan 2008 18:04:42 -0400 (AST) Received: (qmail 3542 invoked by uid 1112); 12 Jan 2008 22:04:41 -0000 Date: Sat, 12 Jan 2008 17:04:41 -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: <200801101153.38782.mljv@planwerk6.de> Message-ID: References: <200801092002.15417.mljv@planwerk6.de> <200801101153.38782.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/592 X-Sequence-Number: 126800 On Thu, 10 Jan 2008, mljv@planwerk6.de wrote: > ah! So it doesn't help if it's the same statement, it has to be the same > object! So DBCP has a statement pool like a map, say > Map > so it can fetch the reference to already existing prepared Statement by > looking at the statement itself, right? Exactly. > But JDBC itself uses the "PREPARE" sql command, right? > So the statement is not really unnamed its name is "" like > prepare "" as select * from table; > execute ""; > > But i can't see any DEALLOCATE statements in my log file. The JDBC driver does not use SQL level PREPARE / DEALLOCATE calls, but instead uses protocol level commands that are pretty much equivalent. The logging process tries to log sql and protocol level commands the same way which is why it shows up that way in the log. Perhaps the server should log the protocol level deallocate as well? > What do you mean with "longer lifespan"? Doesn't the JDBC driver uses the > PREPARE Sql Statement and therefore the prepared Statement has the same > lifespan as the connection? If so, as connections are pooled and never > closed, the prepared Statement will last forever. What if the table analyzes > changes and a better execution plan could be found? > Data and stats changes do not trigger a replan. Kris Jurka