pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: John Lister <john.lister-ps@kickstone.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Query preparation
Date: Wed, 15 Apr 2009 15:42:55 +0300
Message-ID: <49E5D64F.8010603@enterprisedb.com> (raw)
In-Reply-To: <49E4FBB0.40405@kickstone.com>
References: <49E4A6FA.7050407@kickstone.com>
	<49E4AEAC.5000700@opencloud.com>
	<49E4F20C.6040900@kickstone.com>
	<18961.1239742344@sss.pgh.pa.us>
	<49E4FBB0.40405@kickstone.com>

John Lister wrote:
> I appreciate that the send operations (and responses) may be grouped 
> into a single packet, but i was thinking of the scenario (which i would 
> have thought is fairly common) where you prepare the statement and 
> execute it multiple times with different parameters...
> 
> This will result in the parse and describe(portal) commands being sent 
> twice as is (unless i set the prepare threshold to be 1). Admittedly, 
> this will probably not result in any extra packets as the total length 
> of all commands is likely to be less than the packet length (the query 
> size is likely to be the limiting factor here), but this causes extra 
> load on both the server and client - although maybe not enough to worry 
> about.
> 
> I was thinking that you could parse/describe the query just once.

Incidentally, a customer of ours bumped into the overhead of the 
describe portal step just yesterday. It doesn't cause any extra network 
roundtrips, and is usually pretty cheap, but in this case they were 
selecting a single row from a table with 145 columns thousands of times 
in a loop. Furthermore, I believe most of the columns were NULL. They're 
using a PreparedStatement, but we still send the Describe portal message 
on every execution. A quick & dirty patch to cache the RowDescription 
information cut over 10% off the total runtime of the application.

Does anyone see a problem with caching the result set descriptor 
(RowDescription)? AFAICS it should never change after a statement is 
prepared. If not, I'll polish up and submit the patch.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



view thread (15+ messages)  latest in thread

Message-ID: <49E5D64F.8010603@enterprisedb.com>
Permalink:  ../49E5D64F.8010603@enterprisedb.com/
Also on:    postgresql.org/message-id/49E5D64F.8010603@enterprisedb.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: heikki.linnakangas@enterprisedb.com, john.lister-ps@kickstone.com, tgl@sss.pgh.pa.us, oliver@opencloud.com
  Subject: Re: Query preparation
  In-Reply-To: <49E5D64F.8010603@enterprisedb.com>
  References: <49E4A6FA.7050407@kickstone.com> <49E4AEAC.5000700@opencloud.com> <49E4F20C.6040900@kickstone.com> <18961.1239742344@sss.pgh.pa.us> <49E4FBB0.40405@kickstone.com> <49E5D64F.8010603@enterprisedb.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