Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 6A1C02E00FE for ; Wed, 13 Feb 2008 17:13:06 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 95151-07 for ; Wed, 13 Feb 2008 17:13:02 -0400 (AST) Received: from outmail137074.authsmtp.com (outmail137074.authsmtp.com [62.13.137.74]) by postgresql.org (Postfix) with ESMTP id 894802E00CF for ; Wed, 13 Feb 2008 17:13:02 -0400 (AST) Received: from outmail128175.authsmtp.net (outmail128175.authsmtp.net [62.13.128.175]) by punt4.authsmtp.com (8.14.1/8.14.1/Kp) with ESMTP id m1DLC6OZ041800; Wed, 13 Feb 2008 21:12:06 GMT Received: from [192.168.0.3] (85-211-31-42.dyn.gotadsl.co.uk [85.211.31.42]) (authenticated bits=0) by mail.authsmtp.com (8.13.8/8.13.8/Kp) with ESMTP id m1DLCqtY068861; Wed, 13 Feb 2008 21:12:52 GMT Subject: Re: JDBC, prepared queries, and partitioning From: Simon Riggs To: Tom Lane Cc: Kris Jurka , Josh Berkus , PostgreSQL - JDBC In-Reply-To: <23221.1202935654@sss.pgh.pa.us> References: <200802131005.30553.josh@agliodbs.com> <1202934864.16770.486.camel@ebony.site> <23221.1202935654@sss.pgh.pa.us> Content-Type: text/plain Date: Wed, 13 Feb 2008 21:13:42 +0000 Message-Id: <1202937222.16770.505.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit X-Server-Quench: 7044deec-da78-11dc-9670-001185d377ca X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksachtFaQZba1xT HGQLW1xEUlx7WGF/ bggfZQBDYEtPQQZr TkxLXVBXCwUmXB11 em1fFnBycQ1Ofn8+ Z0RhVz5cXEB+IRMo EVMARGoOeGZhPDMC WUZfdx5UcAJLdhoR aVd4ByJDAzANdhEa MyUYCngTER90bGxN WAwVJEgfTQ4SAzMm Rh0ZWX0mG0FNXywp Mx06K1kaHUAeWicA X-Authentic-SMTP: 61633235383639.squirrel.dmpriest.net.uk:787/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/58 X-Sequence-Number: 18265 On Wed, 2008-02-13 at 15:47 -0500, Tom Lane wrote: > Simon Riggs writes: > > On Wed, 2008-02-13 at 13:51 -0500, Kris Jurka wrote: > >> Using protocol version 2 will not prepare queries so constraint exclusion > >> can be used. Just append protocolVersion=2 to your URL. > > > What about the prepare threshold? > I suppose this could be implemented with a GUC variable rather than an > explicit protocol change, but I'm not sure if that'd be a good idea or > not. It's not entirely clear to me which layers on the client side need > to be aware of such behavior. What I liked about prepare threshold was that it gave you the ability to control the re-optimization. ISTM we need a way to say "this query's parameters vary wildly at execution time, so I really need to re-plan it every time". We don't like hints, but that isn't something the database can easily assess. I don't really like the idea of an on/off "replan every time switch". DB2 has that and its a little clunky. I do like the idea of being able to specify re-plan every time (-1) and prepare always (0) or switch from re-plan every time to prepare after (N) executions. Planning with the first set of parameters is OK, but only as long as the first parameter it receives is a "good" one. There's no way to guarantee that without jerking around more than I think we should. We talked about this in 2006 but I think the "Option Node" approach doesn't really cut it from an application developer perspective. -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com