Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D69962E024A for ; Wed, 13 Feb 2008 16:48:05 -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 89337-01-3 for ; Wed, 13 Feb 2008 16:48:02 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id B7CE12E0250 for ; Wed, 13 Feb 2008 16:48:02 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m1DKlYNQ023222; Wed, 13 Feb 2008 15:47:34 -0500 (EST) To: Simon Riggs cc: Kris Jurka , Josh Berkus , PostgreSQL - JDBC Subject: Re: JDBC, prepared queries, and partitioning In-reply-to: <1202934864.16770.486.camel@ebony.site> References: <200802131005.30553.josh@agliodbs.com> <1202934864.16770.486.camel@ebony.site> Comments: In-reply-to Simon Riggs message dated "Wed, 13 Feb 2008 20:34:24 +0000" Date: Wed, 13 Feb 2008 15:47:34 -0500 Message-ID: <23221.1202935654@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/55 X-Sequence-Number: 18262 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? Won't help; the problem is that the planner will never consider a Param value as a true constant. So if you're trying to use out-of-line params to avoid quoting/escaping/SQL-injection-risk issues, you're shut out of constraint exclusion, as well as some other cases such as LIKE optimization. We could imagine having a different operating mode where a generated plan is only used once and so the Param values can be taken as true constants. 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. regards, tom lane