Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D971C632F9F for ; Wed, 15 Apr 2009 09:43:08 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 30377-07 for ; Wed, 15 Apr 2009 09:42:58 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og115.obsmtp.com (exprod7og115.obsmtp.com [64.18.2.217]) by mail.postgresql.org (Postfix) with SMTP id 37ED5632F86 for ; Wed, 15 Apr 2009 09:43:03 -0300 (ADT) Received: from source ([209.85.198.249]) by exprod7ob115.postini.com ([64.18.6.12]) with SMTP ID DSNKSeXWVlvTsIRwhZDEx6LDPp2/FOFiOlyy@postini.com; Wed, 15 Apr 2009 05:43:03 PDT Received: by rv-out-0708.google.com with SMTP id c5so2452041rvf.6 for ; Wed, 15 Apr 2009 05:43:01 -0700 (PDT) Received: by 10.114.137.2 with SMTP id k2mr56776wad.146.1239799381822; Wed, 15 Apr 2009 05:43:01 -0700 (PDT) Received: from ?80.223.212.7? (dsl-hkibrasgw2-fed4df00-7.dhcp.inet.fi [80.223.212.7]) by mx.google.com with ESMTPS id n33sm8772806wag.53.2009.04.15.05.42.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 15 Apr 2009 05:43:00 -0700 (PDT) Message-ID: <49E5D64F.8010603@enterprisedb.com> Date: Wed, 15 Apr 2009 15:42:55 +0300 From: Heikki Linnakangas Organization: EnterpriseDB User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: John Lister CC: Tom Lane , Oliver Jowett , pgsql-jdbc@postgresql.org Subject: Re: Query preparation References: <49E4A6FA.7050407@kickstone.com> <49E4AEAC.5000700@opencloud.com> <49E4F20C.6040900@kickstone.com> <18961.1239742344@sss.pgh.pa.us> <49E4FBB0.40405@kickstone.com> In-Reply-To: <49E4FBB0.40405@kickstone.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200904/58 X-Sequence-Number: 19505 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