Re: ResultSet performance question

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: <cservin(at)cromagnon(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: ResultSet performance question
Date: 2008-12-17 07:41:13
Message-ID: D960CB61B694CF459DCFB4B0128514C202DCBE24@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Craig Servin wrote:
> I'm having a performance issue with Postgresql, but only when using the JDBC
> driver. I'm looking for any suggestions.
>
>
> I have a very simple query that returns about 7000 rows from a temp table.
> Using psql the query returns in under 3 seconds. Using the JDBC driver it
> takes around 30 seconds to run the same query.
>
> I have looked at the query plan using both methods of execution and they are
> identical.

Did you turn on statement tracing on the server an look at the actual query
strings that arrive at the server? Else, how do you know what exactly is executed?

Is there a server side cursor involved in one of this cases? This can change
the execution plan.

> I have played around with setFetchSize() and used
> con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
> But, since I am trying to get all of the results and it is total runtime I am
> worried about server side cursors don't seem applicable.
>
> I have also created a Java class that does nothing but issue rs.next() calls
> through the ResultSet to time the execution without any other work being
> done.

How is the time distributed? Does it take a long time until the first row is
fetched, and the rest comes in almost no time? Or are the 30 seconds more evenly
distributed?

> I can't believe that I am not doing something wrong as the difference in
> execution time is extreme. Is this normal?

If the execution plans are really identical, that would seem out of the
ordinary, even considering Java's comparative slowness.

Yours,
Laurenz Albe

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andres Ledesma 2008-12-17 10:20:56 Re: ResultSet performance question
Previous Message Craig Servin 2008-12-16 19:13:06 ResultSet performance question