Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CAB9F1C20C56 for ; Wed, 16 Nov 2011 20:59:05 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 89765-02 for ; Thu, 17 Nov 2011 00:58:59 +0000 (UTC) Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 475521C20C55 for ; Wed, 16 Nov 2011 20:58:58 -0400 (AST) Received: from nm16-vm0.bullet.mail.ac4.yahoo.com ([98.139.52.238]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RQqJd-0004S2-TN for pgsql-jdbc@postgresql.org; Thu, 17 Nov 2011 00:58:59 +0000 Received: from [98.139.52.196] by nm16.bullet.mail.ac4.yahoo.com with NNFMP; 17 Nov 2011 00:58:44 -0000 Received: from [98.139.52.149] by tm9.bullet.mail.ac4.yahoo.com with NNFMP; 17 Nov 2011 00:58:44 -0000 Received: from [127.0.0.1] by omp1032.mail.ac4.yahoo.com with NNFMP; 17 Nov 2011 00:58:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 577921.13291.bm@omp1032.mail.ac4.yahoo.com Received: (qmail 43266 invoked by uid 60001); 17 Nov 2011 00:58:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1321491524; bh=ieQJlo6ivsdgquYIXPHx2fu62+cOSaGZr1c5pM4t+eU=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=X8hSdotSXafec1D1Vbhk5dE8iS6ar4vXY0ohEO2zeac+B14ZcThMm7qBXirJ1IaSsqjNZcf34SW3orqVVNz3cTPZT6jyofWllYl7xij9qstz+StnX5qP7L97/m1iwu/zEdyX5qDt/bVdEgF1VjYwF9bpKRTHC9gJnyrfR0Zxhjs= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=U3qvDD6WQgc1QqNWUzINjZugZIaC3qRdG2UxH7fFOQY8aVVVZVqcq3Q/SkR2t0kiPIP+7F1Xykss4KJjH6lNDih6kxdpUu8IoAfV0b4IL0vt1hAqz57ylna0rIEIZtqsw/pu46gvep1nvy/ezghKNSIAlLFVNuUPAcbfmRElZ54=; X-YMail-OSG: _FqdHh8VM1nhS6ePng3zu.xADSSkfvLRKQra4jVqCPP9Odi WpP3nxiANUll9UYZj48LdKzKLgVyICaO5SzqDbf5MdCtR7S6Shccyl_CKDpn cS8F2ZF0Vyo2DbIHZ1OMr79ZOR_4ioYxe_qIQ7vHDtpOf8cYnh1pp_gOr.R_ HNA3Cp1OzatsYDwV4HhrTyJjHUFEIPr71kw.XU2O_IOhfY8G_h7VgnsR917p QkLftTGmZTMn2NBhefuyB4xIm7vrukeUa8Hoo59stasONHhA29QCEMJhS.MG WojodJ9ifoH7OQ9XWYNZZmjH13ACY1dsu.mo5ZHVUPq1CkQ_gmMJX1ROiZu3 fZBEAHMdE3sDYEu1WnY5671Q3jqQhLlxvIsxlcnFKZx4uKHkhj2Ywxh57RBX a81iZdzOXas5IGtlhWmeLTnTEbFUVJVvZw7QVRKuutcEshipS4nxF1YxtwVB vr.JzCqYnDYHO8czV3RqEww-- Received: from [70.36.236.24] by web33901.mail.mud.yahoo.com via HTTP; Wed, 16 Nov 2011 16:58:44 PST X-Mailer: YahooMailWebService/0.8.115.325013 References: <1321406281.74175.YahooMailNeo@web33903.mail.mud.yahoo.com> <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.com> <25036.1321490152@sss.pgh.pa.us> Message-ID: <1321491524.39608.YahooMailNeo@web33901.mail.mud.yahoo.com> Date: Wed, 16 Nov 2011 16:58:44 -0800 (PST) From: Anish Kejariwal Reply-To: Anish Kejariwal Subject: Re: avoid prepared statements on complex queries? To: Tom Lane , Kris Jurka Cc: Maciek Sakrejda , "pgsql-jdbc@postgresql.org" In-Reply-To: <25036.1321490152@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="989797710-1854453448-1321491524=:39608" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201111/37 X-Sequence-Number: 22372 --989797710-1854453448-1321491524=:39608 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Tom. =A0That's great to know this will be addressed in 9.2.=0A=0ABtw= - I turned logging on and verified that by setting by setting prepareThres= hold the prepared statement became an unnamed statement. =A0This did not fi= x the performance issue I've been seeing. =A0I'm going to have to resort to= constructing the query myself by building the query string....=0A=0Athanks= for everyones help. =A0=0A=0AAnish=0A=0A=0A=0A____________________________= ____=0AFrom: Tom Lane =0ATo: Kris Jurka =0ACc: Maciek Sakrejda ; Anish Kejariwal ; "pgsql-jdbc@postgresql.org" =0ASent= : Wednesday, November 16, 2011 4:35 PM=0ASubject: Re: [JDBC] avoid prepared= statements on complex queries? =0A=0AKris Jurka writes:= =0A> On Wed, 16 Nov 2011, Maciek Sakrejda wrote:=0A>> Maybe, although I've = never seen that happen and as I understand, the=0A>> driver always sends pa= rameters along with the statement when using=0A>> unnamed statements, so I'= m not sure what would trigger this.=0A=0A> The standard example is "WHERE c= ol LIKE ?".=A0 If the parameter is something =0A> like 'abcdef%' then the q= uery can potentially be converted to a range =0A> scan, but only if knows t= he parameter value.=A0 When preparing this with an =0A> unnamed statement t= he server has the parameter value, but cannot assume =0A> that the same unn= amed statement won't be used with a different parameter =0A> value later an= d must come up with a plan that is correct for all possible =0A> parameters= even if it's not ideal for the current one.=0A=0ABTW, this should be all b= etter in 9.2 ... so if anyone is thinking of=0Aexpending lots of effort to = fix it on the JDBC side, don't bother.=0A=0A=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 r= egards, tom lane --989797710-1854453448-1321491524=:39608 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Tom.  That's gr= eat to know this will be addressed in 9.2.

Btw - I= turned logging on and verified that by setting by setting prepareThreshold= the prepared statement became an unnamed statement.  This did not fix= the performance issue I've been seeing.  I'm going to have to resort = to constructing the query myself by building the query string....

thanks for everyones help.  

= Anish



From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kris Jurka <books@ejurka.com>
Cc: Maciek Sakrejda <msakrejda@truvi= so.com>; Anish Kejariwal <anishkej@yahoo.com>; "pgsql-jdbc@postgre= sql.org" <pgsql-jdbc@postgresql.org>
Sent: Wednesday, November 16, 2011 4:35 PM
Subject: Re: [JDBC] avoid prepared = statements on complex queries?

=0AKris Jurka <books@ejurka.= com> writes:
> On Wed, 16 Nov 2011, Maciek Sakrejda wrote:
= >> Maybe, although I've never seen that happen and as I understand, t= he
>> driver always sends parameters along with the statement when= using
>> unnamed statements, so I'm not sure what would trigger t= his.

> The standard example is "WHERE col LIKE ?".  If the p= arameter is something
> like 'abcdef%' then the query can potentiall= y be converted to a range
> scan, but only if knows the parameter va= lue.  When preparing this with an
> unnamed statement the serve= r has the parameter value, but cannot assume
> that the same unnamed= statement won't be used with a different parameter
> value later an= d must come up with a plan that is correct for all possible
> parame= ters even if it's not ideal for the current one.

BTW, this should be all better in 9.2 ... so if anyone is thin= king of
expending lots of effort to fix it on the JDBC side, don't bothe= r.

            regards,= tom lane


--989797710-1854453448-1321491524=:39608--