Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E214D9F9E03 for ; Mon, 1 Oct 2007 05:39:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 33264-02 for ; Mon, 1 Oct 2007 05:39:49 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190]) by postgresql.org (Postfix) with ESMTP id 5478B9F9EE3 for ; Mon, 1 Oct 2007 05:39:49 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id f5so2344687nfh for ; Mon, 01 Oct 2007 01:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=wO8IKmIibMIv/9+yObSs+FkzDn3Yo/tFa8yL1lAqqw8=; b=hOAAzNp/Ngjg5hU1lHXQk1fA3h8o47JYhllk/CYMmkQPv90BXZgC1mXFbeQynI75CHbG54i7QyQlO671MGyQ+jgOQC3nY1EdbJDSrEbfsdKMoli5+TP4/jPrj4QrlOB+vjcb5nnmgJNP24lOEpY2jc7v5h8V1iFOtY7aymXbJCg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=EC+8pbwIgKJ56ghSmDM/J0Sozes7g68O5S4HdHZsYj6LK6ReIgjSC3XcE2tUSLHjMAHFIwbRAH4t/d5VS24gehTMeevVM/5JZ6oyEE0l5AtcvdImdQa/Dhiu864fFi3ihFLk6HWZhSID0fIkPsCXP9rnjcvl9wnc094bkAVu1zs= Received: by 10.78.177.3 with SMTP id z3mr6016804hue.1191227986035; Mon, 01 Oct 2007 01:39:46 -0700 (PDT) Received: from ?172.24.32.198? ( [62.232.55.118]) by mx.google.com with ESMTPS id k5sm10747322nfh.2007.10.01.01.39.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 01 Oct 2007 01:39:43 -0700 (PDT) Message-ID: <4700B21C.1000008@enterprisedb.com> Date: Mon, 01 Oct 2007 09:38:52 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: lindner@inuus.com CC: Oliver Jowett , Josh Berkus , pgsql-jdbc@postgresql.org Subject: Re: Prepared Statements vs. pgbouncer References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> <20070929021522.GH3140@inuus.com> <24584.1191033096@sss.pgh.pa.us> <20070929072159.GI3140@inuus.com> <46FE3B1A.7020603@agliodbs.com> <46FED7FA.6060309@opencloud.com> <46FFC314.5080205@agliodbs.com> <47000C2E.8030409@opencloud.com> In-Reply-To: <47000C2E.8030409@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/5 X-Sequence-Number: 17577 Oliver Jowett wrote: > Josh Berkus wrote: >> Oliver, >> >>> S_1 from client 1 might be a completely different query to S_1 from >>> client 2. The JDBC driver just numbers statements sequentially as >>> they are used. >> >> So, how does j2EE-side connection pooling handle this? > > Err.. it is dealing with JDBC connections, not protocol level stuff, so > there's no issue with statement naming. The driver just does what it > normally does (maintains a mapping of query to statement name on each > connection). The usual J2EE connection pool model is different to what > pgbouncer apparently does as clients explicitly return connections to > the pool when no longer needed -- which effectively invalidates any > PreparedStatement objects they might still be holding -- and reobtain > them when later need. The OP might be better off doing the connection multiplexing at a higher level as well. You could use something like Virtual JDBC (vjdbc.sourceforge.net) between the clients and a connection pool managed in the multiplexer. There would be no problem with prepared statements, since the JDBC driver would deal with real connections to the database. I've never used vjdbc myself, so I don't know if it's applicable, but something along those lines should work. You might also consider if using pgbouncer or similar really is necessary. Perhaps you could get away with a per-client connection pool, with "min pool size" small enough, maybe 0, that the number of simultaneous connections to the server would stay reasonable. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com