Re: JDBC, prepared queries, and partitioning - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: JDBC, prepared queries, and partitioning
Date
Msg-id 23221.1202935654@sss.pgh.pa.us
Whole thread Raw
In response to Re: JDBC, prepared queries, and partitioning  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: JDBC, prepared queries, and partitioning  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-jdbc
Simon Riggs <simon@2ndquadrant.com> 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

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: JDBC, prepared queries, and partitioning
Next
From: Simon Riggs
Date:
Subject: Re: JDBC, prepared queries, and partitioning