From: Oliver Jowett <oliver@opencloud.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Cc: tgl@sss.pgh.pa.us
Subject: Re: v3proto Parse/Bind and the query planner
Date: Wed, 19 May 2004 12:50:26 +1200
Message-ID: <40AAAF52.9040501@opencloud.com> (raw)
In-Reply-To: <Pine.BSO.4.56.0405181854380.21058@leary.csoft.net>
References: <40A84236.6070809@opencloud.com>
<Pine.BSO.4.56.0405171600500.24398@leary.csoft.net>
<40AAA131.3010602@opencloud.com>
<Pine.BSO.4.56.0405181854380.21058@leary.csoft.net>
Kris Jurka wrote:
>
> On Wed, 19 May 2004, Oliver Jowett wrote:
>
>
>>Instead, how about something like:
>>
>> - For named statements, plan at Parse time always.
>> - For unnamed statements, plan at Bind time always.
>>
>>The assumption here is that if the client is using the unnamed
>>statement, it's unlikely that it will be repeatedly reusing that
>>statement with different parameter values so there is little benefit to
>>preserving the query plan at the cost of being unable to plan for
>>specific parameter values. If the client is using named statements,
>>there's no change in behaviour from the current approach, so presumably
>>the client knows what it's doing! :)
>
>
> I was under the impression that the query protocol would Parse once and
> then Bind/Execute for each execution of a statement.
Yes.
> If that's true we
> can't use the unnamed portal because it can be destroyed if a
> multithreaded app is using two Statements simultaneously. The lock on
> pgstream will be given up between executions of a statement.
By default we re-Parse on each subsequent execution. The Parse is only
skipped if there is a named statement corresponding to the query being
executed (i.e. we previously sent a named Parse and got a corresponding
ParseComplete back). So there's no threading issue, just the cost
(hopefully small if planning is not being done) of re-Parsing the
statement on each execution.
This is already in my v3 changes. The named-vs-unnamed distinction is
controlled by a query flag (QUERY_ONESHOT) rather than by whether the
query is parameterized or not -- it'll support unnamed statements that
have parameters with no changes. Currently QUERY_ONESHOT is only passed
when executing queries via the direct-execution Statement interface, but
it'd easy to hook up to the state of the useServerPrepare flag for the
PreparedStatement case.
-O
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, books@ejurka.com, tgl@sss.pgh.pa.us
Subject: Re: v3proto Parse/Bind and the query planner
In-Reply-To: <40AAAF52.9040501@opencloud.com>
References: <40A84236.6070809@opencloud.com> <Pine.BSO.4.56.0405171600500.24398@leary.csoft.net> <40AAA131.3010602@opencloud.com> <Pine.BSO.4.56.0405181854380.21058@leary.csoft.net> <40AAAF52.9040501@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