pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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 21:29:00 +0100
Message-ID: <49E4F20C.6040900@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.
>   
Just going through the code again and please correct me if i'm wrong, 
but at the moment there is unnecessary network traffic/latency. Assuming 
a PreparedStatement, every time execute is called, sendParse and 
sendDescribePortal are called (the former checks if a server side 
prepared statement has been created and aborts if so). Admittedly 
sendParse is only called as many times as setPrepareThreshold is set to 
(which admittedly may be as low as 1)

Apart from the use of unnamed statements/portals within a multi threaded 
environment which complicates things with parsing, i would have thought 
you could get away with calling describe(portal) just once.

I appreciate that it would need a lot of refactoring to move things 
around, but are there any objections?
Also, i don't know how many server side prepared statements/portals 
postgresql supports (hopefully memory limited) but would it also not 
make more sense to make all preparedStatements actually be server side 
preparedStatements. I can't see what overhead this would add apart from 
named statements/portals

I'd be happy to look into this if there was support...

Thanks



view thread (15+ messages)  latest in thread

Message-ID: <49E4F20C.6040900@kickstone.com>
Permalink:  ../49E4F20C.6040900@kickstone.com/
Also on:    postgresql.org/message-id/49E4F20C.6040900@kickstone.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: john.lister-ps@kickstone.com, oliver@opencloud.com
  Subject: Re: Query preparation
  In-Reply-To: <49E4F20C.6040900@kickstone.com>
  References: <49E4A6FA.7050407@kickstone.com> <49E4AEAC.5000700@opencloud.com> <49E4F20C.6040900@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