Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 1F9E111F2009 for ; Wed, 16 Nov 2011 16:38:15 -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 22881-08 for ; Wed, 16 Nov 2011 20:38:08 +0000 (UTC) Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 90B4B11F2006 for ; Wed, 16 Nov 2011 16:38:08 -0400 (AST) Received: from nm24-vm1.bullet.mail.ne1.yahoo.com ([98.138.90.45]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1RQmFC-00015a-Uj for pgsql-jdbc@postgresql.org; Wed, 16 Nov 2011 20:38:08 +0000 Received: from [98.138.90.48] by nm24.bullet.mail.ne1.yahoo.com with NNFMP; 16 Nov 2011 20:37:54 -0000 Received: from [98.138.89.249] by tm1.bullet.mail.ne1.yahoo.com with NNFMP; 16 Nov 2011 20:37:54 -0000 Received: from [127.0.0.1] by omp1041.mail.ne1.yahoo.com with NNFMP; 16 Nov 2011 20:37:54 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 52307.29872.bm@omp1041.mail.ne1.yahoo.com Received: (qmail 761 invoked by uid 60001); 16 Nov 2011 20:37:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1321475873; bh=we6QbP34IQHIdR7ZgzExD85RwFE3W+RCKlfoZldUfns=; 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=dTh14e0OncSpR2WNemoFgitrYVOFbSKAyZOPW22qpbbndEQGaURIZE2sXz7UCfOonLYfRnw6DprxAjwScI8J7HgtMsYeR5ShZjnyG2lEll4/WCqXc1bphdm++FFWUXi8k1dyXIzbaz2wOmYfB07q9CXhQ5m2yC+v+Oe3f3W7sdw= 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=h9nqWTBd684A1G/p2sqmCxcTAYV5qK5R6ttk4Q1xXHHt2EEH3dI1uuQuPlHj9KZlVCOgcmfo6wHu8UOBq5xklxx+J2N3gwzqr4NinZTZWde1NrLYAEZI6O7BU//xYXj01zxiihVahhZILjgbPJKYHLBQtfyrgTiOzeyeArZm0XU=; X-YMail-OSG: VKoMoX4VM1nT1HIsv_ScI7Lp759ByuojkOBpZeMO3kpelon j6UMnzjYh1ko0HxbVeoMhZNYCsDMYH5LCE.oWwBx6QK0GdUG86K1_ldXacwk 8VoGKKXN6fshqzmE8NOVoo9YkNwZ_fHWdL3h2yjVKKpRauwo50Pbjv_q9c3B k0AJYaRREDb8sHBjsbq_Qu2p1HQrW90UWTCXj.YeHWjf8d3X4ImejWn4uw8z HTilBkY.oRKRrVP2OwHJhcileq_NPPS.92Q.FDMcjOvVcHiy7HBfYOVDfWw0 iYTKTSpZeN_235WJ6u3FkvKQJyekye4tedM_LgkrWwoGUUQPZGt4gyiVLK8T 9Ynvc.9EfbFXUswv8wi4rPUYrBxIV7e2z1wCR.LWRX5PpzS3_YdXQFpZzkp2 p0bBrR6kzrklX1H3voqZK9Xt4dtyW59IUpn5O4uWj966Vbe445jIyGw0v_iZ 9qszlUJ1YS7coYeCiYeZay8asKRsBT6sGGsMA4T8J.9GQTlXobJeYEaKWIzV LUuckYYv4bhmwg3_QAVrxoQ-- Received: from [70.36.236.24] by web33905.mail.mud.yahoo.com via HTTP; Wed, 16 Nov 2011 12:37:53 PST X-Mailer: YahooMailWebService/0.8.115.325013 References: <1321406281.74175.YahooMailNeo@web33903.mail.mud.yahoo.com> Message-ID: <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.com> Date: Wed, 16 Nov 2011 12:37:53 -0800 (PST) From: Anish Kejariwal Reply-To: Anish Kejariwal Subject: Re: avoid prepared statements on complex queries? To: Maciek Sakrejda Cc: "pgsql-jdbc@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="360468559-926136562-1321475873=:74818" 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/28 X-Sequence-Number: 22363 --360468559-926136562-1321475873=:74818 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Maciek,=0A=0AI tried playing around with the prepareThreshold parameter,= by setting it in the JDBC connection string. =A0I tried setting it to zero= , which should cause it to not use a prepared statement, right? =A0Query is= still slow. =A0I also tried setting it to 1 and 3, and in all cases it's s= low. =A0Is there any way to verify if postgres is using a planned query?=0A= =0AI found this old post:=0Ahttp://archives.postgresql.org/pgsql-jdbc/2008-= 02/msg00077.php=0A"However even when plans are not cached, you will still r= un into the issue that an unnamed statement using out-of-line parameter val= ues may generate a less efficient plan than an unnamed statement using inli= ne parameter values, because there is no way to tell the planner at the pro= tocol level "I am really only ever using this query once, please give me a = specific plan for these values and don't worry about generating a plan that= is correct for other values too"."=0A=0AMaybe that's what's happening?=0A= =0AI tried a different tactic: setting the protocolVersion=3D2. =A0I can se= e that forces it to not use a prepared statement, but it seems to ignore th= at I set the fetch size to 1000 for the prepared statement. =A0I need to be= able to set the fetch size, otherwise I run out of memory since I'm gettin= g back 4 million results.=0A=0Athanks for your help.=0A=0AAnish=0A=0A=0A=0A= ________________________________=0AFrom: Maciek Sakrejda =0ATo: Anish Kejariwal =0ACc: "pgsql-jdbc@postgres= ql.org" =0ASent: Tuesday, November 15, 2011 5:31= PM=0ASubject: Re: [JDBC] avoid prepared statements on complex queries?=0A= =0A> If only there was a way to have parameterized queries without using pr= epared=0A> statements....=0A=0ATake a look at the prepareThreshold connecti= on string parameter.=0A---=0AMaciek Sakrejda | System Architect | Truviso= =0A=0A1065 E. Hillsdale Blvd., Suite 215=0AFoster City, CA 94404=0A(650) 24= 2-3500 Main=0Awww.truviso.com --360468559-926136562-1321475873=:74818 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Maciek,

I tried play= ing around with the prepareThreshold parameter, by setting it in the JDBC c= onnection string.  I tried setting it to zero, which should cause it t= o not use a prepared statement, right?  Query is still slow.  I a= lso tried setting it to 1 and 3, and in all cases it's slow.  Is there= any way to verify if postgres is using a planned query?

I found this old post:
http://archives.postgresql.org/pgsq= l-jdbc/2008-02/msg00077.php
"However even when plans are not cach= ed, you will still run into the issue that an unnamed statement using out-o= f-line parameter values may generate a less efficient plan than an unnamed = statement using inline parameter values, because there is no way to tell the planner at the protocol level "I am really only ever using this query = once, please give me a specific plan for these values and don't worry about= generating a plan that is correct for other values too"."

Maybe that's what's happening?

I tried a = different tactic: setting the protocolVersion=3D2.  I can see that for= ces it to not use a prepared statement, but it seems to ignore that I set t= he fetch size to 1000 for the prepared statement.  I need to be able t= o set the fetch size, otherwise I run out of memory since I'm getting back = 4 million results.

thanks for your help.

Anish

=0A=0A=0A=0A= =0A=0A=0A=0A

From: Maciek Sa= krejda <msakrejda@truviso.com>
To: Anish Kejariwal <anishkej@yahoo.com>
Cc: "pgsql-jdbc@postgresql.org" <p= gsql-jdbc@postgresql.org>
Sent:= Tuesday, November 15, 2011 5:31 PM
Subject: Re: [JDBC] avoid prepared statements on co= mplex queries?

=0A> If only there was a way to have parame= terized queries without using prepared
> statements....

Take a= look at the prepareThreshold connection string parameter.
---
Maciek= Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suit= e 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com


--360468559-926136562-1321475873=:74818--