From: John Lister <john.lister-ps@kickstone.com>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Query preparation
Date: Tue, 14 Apr 2009 18:19:02 +0100
Message-ID: <49E4C586.4070107@kickstone.com> (raw)
In-Reply-To: <49E4AEAC.5000700@opencloud.com>
References: <49E4A6FA.7050407@kickstone.com>
<49E4AEAC.5000700@opencloud.com>
Oliver Jowett wrote
> John Lister wrote:
>
>> Hi, i was wondering if there is any reason why the query preparation is
>> done when the query is executed instead of when the preparedStatement is
>> created.
>>
>
> It would be an extra network round-trip on every query, and there's no
> requirement to prepare it early.
>
>
I'm not sure why it would be there would be an extra round trip? The
parse is done anyway, the only extra round trip would be if you did a
describe (which admittedly i'm looking into optionally doing for binary
transfers) or if you didn't use the preparedStatement to do any queries
which is i'd imagine is rare.
Maybe i've missed something?
>> Has any one looked into moving it?
>>
>
> Why would you want to move it?
>
>
To me it would be cleaner, it looks like the current driver was written
prior to v3 of the protocol where only simple queries are used and
everything is transmitted as text. The extended protocol stuff has been
bolted subsequently to the execute part of the driver rather than doing
it when the query is prepared... btw, i have nothing but respect for the
writers after doing some work on the another driver some years ago.
Also, in fairness i've done a lot of work with the oracle stuff vwhich
create portals (cursors) and prepare the statement before the execution
and this makes more sense to me.
Also, with regard to extra network traffic and latency i'm not
suggesting changing the way normal statements are used, only
PreparedStatements. This to me fits in more with the way the JDBC spec
is worded and i'd guess the more usual use case of statements -
Statement for quick and dirty one off queries, PreparedStatement for
more complicated/multiple use queries.
JOHN
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: john.lister-ps@kickstone.com, oliver@opencloud.com
Subject: Re: Query preparation
In-Reply-To: <49E4C586.4070107@kickstone.com>
References: <49E4A6FA.7050407@kickstone.com> <49E4AEAC.5000700@opencloud.com> <49E4C586.4070107@kickstone.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