pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jwollman <jwollman@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Slow statement when using JDBC
Date: Tue, 30 Jul 2013 11:32:34 -0700 (PDT)
Message-ID: <1375209154731-5765663.post@n5.nabble.com> (raw)
In-Reply-To: <AANLkTimSzT6JkWkxJwNpWhSNLbcxaymREFHf3vAoYZTX@mail.gmail.com>
References: <AANLkTik_Ww_gGcNF2ntN0Emq5_KGvLN2WSDnC4BQiSTC@mail.gmail.com>
	<AANLkTik5eqiMj-GZDahLJ1HiL==xfQGxp-wZbxJwnBws@mail.gmail.com>
	<AANLkTimSzT6JkWkxJwNpWhSNLbcxaymREFHf3vAoYZTX@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

There was no end to this thread so, as I have just run into this problem, I
thought I post.

I can validate Yazen problem using Prepared statements as not a JDBC problem
but actually a problem that exists in pre-9.2 versions of Postgres.

I work for a company that provides a product with an embedded database.  We
currently have Postgres version 9.0.3 and have run into the exact same
problem: Prepared Statements with Bind Variables run significantly slower
than statements without Bind Variables either via JDBC or in database
itself.

I took the slow running Prepared Statement with Bind Variables from our
application and replicated the same exact problem by running it against same
version 9.0.3 of Postgres in pg_Admin using Prepare foo as <prepared
statement>;  Execute foo ('xxxx', 'yyyy');
          The query took 40,000ms to run.
          (I also took same query and resolved bind variables to actual
values and ran in the same manner as a prepared statement. The query took
111ms to run.)

I also took the same query with Bind Variables and ran as Prepared Statement
using the same dataset but on version 9.2.4 of Postgres.
         The query took 77ms and used a reasonable explain plan.

Conclusion: this appears to be a database problem due to odd explain plan
for Prepared Statements with Bind Variables.  Kevin Grittner's comment in
this thread seems to be a good explanation.

Good news: that this was validated as a bug and was fixed by Tom Lane in
version 9.2 of Postgres. See:
http://stackoverflow.com/questions/12368338/how-to-make-postgresql-optimizer-to-build-execution-plan...
<http://stackoverflow.com/questions/12368338/how-to-make-postgresql-optimizer-to-build-execution-plan...;  
Thanks,
Jon Wollman
Portfolio Data Architect, Rapid7



--
View this message in context: http://postgresql.1045698.n5.nabble.com/Slow-statement-when-using-JDBC-tp3368379p5765663.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (17+ messages)  latest in thread

Message-ID: <1375209154731-5765663.post@n5.nabble.com>
Permalink:  ../1375209154731-5765663.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1375209154731-5765663.post@n5.nabble.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: jwollman@yahoo.com
  Subject: Re: Slow statement when using JDBC
  In-Reply-To: <1375209154731-5765663.post@n5.nabble.com>
  References: <AANLkTik_Ww_gGcNF2ntN0Emq5_KGvLN2WSDnC4BQiSTC@mail.gmail.com> <AANLkTik5eqiMj-GZDahLJ1HiL==xfQGxp-wZbxJwnBws@mail.gmail.com> <AANLkTimSzT6JkWkxJwNpWhSNLbcxaymREFHf3vAoYZTX@mail.gmail.com> <1375209154731-5765663.post@n5.nabble.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