Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 19DC81337C1F for ; Fri, 15 Oct 2010 17:04:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 31032-09-2; Fri, 15 Oct 2010 20:03:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from acidenitrix.villemain.org (acidenitrix.villemain.org [91.121.90.165]) by mail.postgresql.org (Postfix) with ESMTP id B38391337BBE; Fri, 15 Oct 2010 17:03:48 -0300 (ADT) Received: from 89-158-241-48.rev.dartybox.com ([89.158.241.48] helo=DimIMac.local) by acidenitrix.villemain.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P6qVD-00076n-8S; Fri, 15 Oct 2010 22:03:43 +0200 Received: by DimIMac.local (Postfix, from userid 501) id 092091043CF1; Fri, 15 Oct 2010 22:03:35 +0200 (CEST) From: Dimitri Fontaine To: Stephen Frost Cc: Tom Lane , =?utf-8?Q?Rados=C5=82aw?= Smogura , Magnus Hagander , David Fetter , Kevin Grittner , PG Hackers , PostgreSQL JDBC List , robertmhaas@gmail.com Subject: Re: [JDBC] Support for JDBC setQueryTimeout, et al. Organization: 2ndQuadrant References: <88dcb3988805ede17af4a460ad251534@smogura-softworks.eu> <20101012141439.GA29627@fetter.org> <4CB43A4C0200002500036826@gw.wicourts.gov> <20101012155531.GB29627@fetter.org> <528f31015d6bf68650646b9b4ba71a10@smogura-softworks.eu> <20101015142126.GQ26232@tamriel.snowman.net> <20260.1287153534@sss.pgh.pa.us> <20101015145248.GR26232@tamriel.snowman.net> User-Mail-Address: dimitri@2ndQuadrant.fr Date: Fri, 15 Oct 2010 22:03:35 +0200 In-Reply-To: <20101015145248.GR26232@tamriel.snowman.net> (Stephen Frost's message of "Fri, 15 Oct 2010 10:52:48 -0400") Message-ID: User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (darwin) MIME-Version: 1.0 Content-Type: text/plain X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201010/1046 X-Sequence-Number: 172086 Stephen Frost writes: > That assumption is certainly something I feel we should consider a valid > and important use-case. I'd think a lot of the time your typical website > is going to be using a dedicated pooler for connections and a dedicated > database where having those queries cache'd would be good. Using pgbouncer without setting server_reset_query is possible and allow to reuser prepared queries. I abuse the feature in some environment where prepare takes ~42ms and execute 5ms, as all the data is in RAM. > I recall seeing a module that even set things up so you feed it all the > queries that you're going to run and it plans them all out for you when > you start up the pooler. Been meaning to look into it more, but.. Yeah, for this same project I wanted the application code to stop having to check whether the session given already has the queries prepared. As pgbouncer will take new connections here and there (which is a good idea), you have to check for that. Enters preprepare: http://preprepare.projects.postgresql.org/README.html http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/preprepare/preprepare/ http://packages.debian.org/sid/postgresql-8.4-preprepare There's no release yet and the code is still under CVS, but I could see about moving it to github some day. Well, maybe I also should implement support for 9.0. > The whole problem with search_path and role is very frustrating. We've > taken to just hacking things to be dynamic SQL whenever it's > role-specific, but that's a really poor solution. I wonder if it would > be possible to have the function and prepare'd plan caches be key'd off > of the search_path and role too..? So if you change one of those you > end up having to re-plan it, but then that's also cached, etc.. By default pgbouncer maintains a different pool per database and role, so you should be partly covered here. Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support