Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1456A633603 for ; Tue, 12 May 2009 15:50:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 16442-10 for ; Tue, 12 May 2009 15:50:15 -0300 (ADT) Received: from mx3.hub.org (mx3.hub.org [206.223.169.73]) by mail.postgresql.org (Postfix) with ESMTP id 411F3633386 for ; Tue, 12 May 2009 15:50:18 -0300 (ADT) X-Greylist: delayed 04:21:51.479271 by SQLgrey-1.7.6 Received: from kerberos.fcon.no (165.84-49-232.nextgentel.com [84.49.232.165]) by mx3.hub.org (Postfix) with ESMTP id C29F637B965 for ; Tue, 12 May 2009 15:50:17 -0300 (ADT) Received: from [10.0.0.38] (duplo.lan [10.0.0.38]) by kerberos.fcon.no (Postfix) with ESMTP id 572D5370A6 for ; Tue, 12 May 2009 20:50:14 +0200 (CEST) Message-ID: <4A09C4E6.3010408@fcon.no> Date: Tue, 12 May 2009 20:50:14 +0200 From: Thomas Finneid User-Agent: Thunderbird 2.0.0.21 (X11/20090302) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: pooled prepared statements References: <4A0978A3.6030900@fcon.no> <4A099C8F.60709@kickstone.com> In-Reply-To: <4A099C8F.60709@kickstone.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL=0.050 X-Spam-Level: X-Archive-Number: 200905/65 X-Sequence-Number: 19615 Probably easier to create a server side function instead, then. regards thomas John Lister wrote: > Thomas Finneid wrote: >> When a PreparedStatment is created by a pooled connection, as far as I >> understand if, that creation happens on the server side, and a >> reference, of sorts, is returned to the client jdbc. >> >> Is that prepared statement shared among the connections or is it only >> available to that single connection? and more importantly, can many >> connections use that prepared statement concurrently? >> >> If it is shared, then it must be usable by concurrent connections, >> otherwise it will be difficult for the client to know if the statement >> is occupied or not. So I just want to confirm that I understand how >> the JDBC driver works. > Once the query usage count exceeds the prepareThreshold parameter, then > the driver does create a "prepare statement object" on the server. This > is only valid for the time the PreparedStatement is open and only on > that connection. So to answer your question, they cannot be shared by > multiple connections. > > You can create your own using the PREPARE and EXECUTE sql commands so > long as you track them across different connections... > > I'll admit this would be a nice feature for things like JPA where you > end up creating lots of preparedStatements on different connections, > reusing or caching a single one may be a worthwhile performance > optimisation - although not sure about how you would implement it nicely.. > > JOHN >