pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: josh@agliodbs.com
Cc: Stephen Denne <Stephen.Denne@datamail.co.nz>
Cc: Kris Jurka <books@ejurka.com>
Cc: PostgreSQL - JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: JDBC, prepared queries, and partitioning
Date: Thu, 14 Feb 2008 12:37:53 +1300
Message-ID: <47B37F51.2010003@opencloud.com> (raw)
In-Reply-To: <47B37BDA.8020702@opencloud.com>
References: <200802131005.30553.josh@agliodbs.com>
	<F0238EBA67824444BC1CB4700960CB4804A4F683@dmpeints002.isotach.com>
	<1202939756.16770.517.camel@ebony.site>
	<200802131423.24613.josh@agliodbs.com>
	<47B37549.3@opencloud.com>
	<1202944752.16770.568.camel@ebony.site>
	<47B37BDA.8020702@opencloud.com>

Oliver Jowett wrote:
> Simon Riggs wrote:
> 
>> What we need is a "send parameters inline" mode that can be set as an
>> option for a PreparedStatement. Nobody wants to use V2, we just want the
>> ability to re-plan a query every time. Perhaps that is best implemented
>> as a server side option that can be exposed via JDBC option, since this
>> is an SQL requirement and nothing to do with Java.
> 
> Unfortunately you can't have your cake and eat it too. Many of the 
> features specific to V3 *require* that parameters be sent out of line 
> (e.g. parameter metadata, bytea streaming, possibly OUT parameters)
> 
> As Kris said earlier in this thread what we really need is a way to tell 
> the server "I will only ever use this statement once, with these 
> particular parameter values, go ahead and optimize the plan on that basis"

Another possibility is to make the unnamed statement behaviour in the 
server more aggressive.

The current behaviour is that planning only happens on the first Bind of 
a particular unnamed statement, and parameter placeholders are left as 
placeholders in the plan tree, with logic to pull in actual parameter 
values when doing cost estimates involving those nodes.

Instead, we could change that so that whenever a Bind for the unnamed 
statement is received, the query is replanned. Before the normal 
optimization is run, the actual parameter values are substituted into 
the parse/plan tree as constants (and so are subject to all the normal 
optimizations such as constant folding and the constraint/partition 
stuff). After execution we should discard the plan, since it's tied to 
specific values. If that same unnamed statement gets reexecuted with 
different parameter values later, no harm done - we replan it again with 
the new values.

I vaguely remember suggesting something like this back in my changes to 
8.0, but it was going to be too much of a change to the protocol 
behaviour. Given the hindsight of a few major versions, are there 
actually clients that reuse the unnamed statement in use, and would they 
be badly affected by this change?

-O



view thread (41+ messages)  latest in thread

Message-ID: <47B37F51.2010003@opencloud.com>
Permalink:  ../47B37F51.2010003@opencloud.com/
Also on:    postgresql.org/message-id/47B37F51.2010003@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, simon@2ndquadrant.com, josh@agliodbs.com, Stephen.Denne@datamail.co.nz, books@ejurka.com
  Subject: Re: JDBC, prepared queries, and partitioning
  In-Reply-To: <47B37F51.2010003@opencloud.com>
  References: <200802131005.30553.josh@agliodbs.com> <F0238EBA67824444BC1CB4700960CB4804A4F683@dmpeints002.isotach.com> <1202939756.16770.517.camel@ebony.site> <200802131423.24613.josh@agliodbs.com> <47B37549.3@opencloud.com> <1202944752.16770.568.camel@ebony.site> <47B37BDA.8020702@opencloud.com> <47B37F51.2010003@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox