Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E01049F9A8F for ; Sat, 29 Sep 2007 04:22:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 77757-04 for ; Sat, 29 Sep 2007 04:22:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mirth.inuus.com (mirth.inuus.com [67.100.95.85]) by postgresql.org (Postfix) with ESMTP id 0F3D69F9A8E for ; Sat, 29 Sep 2007 04:22:21 -0300 (ADT) Received: from mirth.inuus.com (localhost.localdomain [127.0.0.1]) by mirth.inuus.com (8.14.1/8.14.1) with ESMTP id l8T7M0xY013156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 29 Sep 2007 00:22:00 -0700 Received: (from lindner@localhost) by mirth.inuus.com (8.14.1/8.14.1/Submit) id l8T7Lx80013155; Sat, 29 Sep 2007 00:21:59 -0700 X-Authentication-Warning: mirth.inuus.com: lindner set sender to lindner@inuus.com using -f Date: Sat, 29 Sep 2007 00:21:59 -0700 From: Paul Lindner To: Tom Lane Cc: Paul Lindner , Oliver Jowett , pgsql-jdbc@postgresql.org Subject: Re: Prepared Statements vs. pgbouncer Message-ID: <20070929072159.GI3140@inuus.com> References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> <20070929021522.GH3140@inuus.com> <24584.1191033096@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sl5MdczEF/OU2Miu" Content-Disposition: inline In-Reply-To: <24584.1191033096@sss.pgh.pa.us> User-Agent: Mutt/1.5.14 (2007-02-12) X-Virus-Scanned: ClamAV 0.91.2/4426/Fri Sep 28 22:28:01 2007 on mirth.inuus.com X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/138 X-Sequence-Number: 17560 --sl5MdczEF/OU2Miu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I appear to have stirred the pot a little too vigorously.. Let's take a deep breath and take a step back.. First off, I really appreciate the hard work that's gone into the design and implementation of Postgres and the JDBC driver. I realize that what I'm trying to do falls outside of the norms -- hopefully the following background information will help everyone understand what I'm trying to achieve: The environment: * 100s of application servers using Torque and DBCP * Dozens of databases. * All app servers can connect to all databases. * Each application server may need many connections to an individual database. * App code as written will spawn multiple concurrent SELECTs to a single database to speed up queries on partitioned tables. Okay.. So given those parameters we've been able to tune the system to use about 2000 maxconns on the DBs, and a max of 8 connections from each application server. In spite of that the majority of connections are idle. So we kill off idle backends with cron.. Not ideal, but it's worked so far..=20 Okay... now let's double or triple the number of application servers.. That means either: 1. Going to 4k or 6k backend maxconns. 2. Halving or thirding the number of simultaneous conns for each app serv= er. 3. Use pgbouncer to allow 6k connections while actually lowering the number of DB backends, plus giving us some very cool maintenance features like redirecting connections to other hosts and more. So we we're trying to implement #3. If others have better ideas I'm all ears. Our pgbouncer config will keep a connection on the same backend for the duration of an individual transaction. The only thing holding us back from deploying the pgbouncer solution is this issue with the server-side prepared statements. =20 Possible solutions: * Use protocolVersion=3D2, since 7.3 does not support server side prepare.. * Modify jdbc driver to use unique prefixes for server-side=20 prepared statements. Build my own jar and deploy. * Request help to solve this the 'correct' way. I realize that this environment is not so common. All I ask is help in making it possible. FWIW it seems that Oracle has something similar in 11g named DRCP: http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf So maybe it's not such an uncommon case after all... Thanks in advance for any assistence, pointers, tips on this matter. On Fri, Sep 28, 2007 at 10:31:36PM -0400, Tom Lane wrote: > Paul Lindner writes: > > It seems that the driver should immediately deallocate the server-side > > prepared statements it creates for cursors when it finishs fetching > > data for that cursor. >=20 > What exactly is the argument here? That no client should use anything > more than the fraction of the FE/BE protocol that pgbouncer currently > supports? Pardon me for not buying into it. >=20 > regards, tom lane --=20 Paul Lindner ||||| | | | | | | | | | lindner@inuus.com --sl5MdczEF/OU2Miu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG/f0W+FkoUnP1gFQRArt6AJ9pNe/fga5Mef30lf5rHzFyghwP8gCeJIDY K24Zo9jSeqkK6490vX+gC5U= =hs9v -----END PGP SIGNATURE----- --sl5MdczEF/OU2Miu--