From: Anish Kejariwal <anishkej@yahoo.com>
To: Maciek Sakrejda <msakrejda@truviso.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: avoid prepared statements on complex queries?
Date: Wed, 16 Nov 2011 12:37:53 -0800 (PST)
Message-ID: <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.com> (raw)
In-Reply-To: <CAH_hXRb6iGy7A0oUJ_DJipNqDG=JM54h4t+JH7awfH8NBAneSg@mail.gmail.com>
References: <1321406281.74175.YahooMailNeo@web33903.mail.mud.yahoo.com>
<CAH_hXRb6iGy7A0oUJ_DJipNqDG=JM54h4t+JH7awfH8NBAneSg@mail.gmail.com>
Hi Maciek,
I tried playing around with the prepareThreshold parameter, by setting it in the JDBC connection string. I tried setting it to zero, which should cause it to not use a prepared statement, right? Query is still slow. I also 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/pgsql-jdbc/2008-02/msg00077.php
"However even when plans are not cached, you will still run into the issue that an unnamed statement using out-of-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=2. I can see that forces it to not use a prepared statement, but it seems to ignore that I set the fetch size to 1000 for the prepared statement. I need to be able to set the fetch size, otherwise I run out of memory since I'm getting back 4 million results.
thanks for your help.
Anish
________________________________
From: Maciek Sakrejda <msakrejda@truviso.com>
To: Anish Kejariwal <anishkej@yahoo.com>
Cc: "pgsql-jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Sent: Tuesday, November 15, 2011 5:31 PM
Subject: Re: [JDBC] avoid prepared statements on complex queries?
> If only there was a way to have parameterized queries without using prepared
> statements....
Take a look at the prepareThreshold connection string parameter.
---
Maciek Sakrejda | System Architect | Truviso
1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com
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: anishkej@yahoo.com, msakrejda@truviso.com
Subject: Re: avoid prepared statements on complex queries?
In-Reply-To: <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.com>
References: <1321406281.74175.YahooMailNeo@web33903.mail.mud.yahoo.com> <CAH_hXRb6iGy7A0oUJ_DJipNqDG=JM54h4t+JH7awfH8NBAneSg@mail.gmail.com> <1321475873.74818.YahooMailNeo@web33905.mail.mud.yahoo.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