From: Frédéric Houbie <fh@ionicsoft.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Postgres 8.2 and setFetchSize
Date: Wed, 19 Sep 2007 14:12:13 +0200
Message-ID: <95484F7A889A61469885286054F675DD51252A@altarf.ionicsoft.com> (raw)
References: <95484F7A889A61469885286054F675DD512526@altarf.ionicsoft.com>
I have one more information, I tried the same code using my local Postgres database (on my XP, 8.2.4), it is working. What can I check on the server to see what's wrong ?
In my log, I can see it is using a cursor
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms parse S_1: BEGIN
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms bind S_1: BEGIN
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms execute S_1: BEGIN
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms parse S_2: SELECT * FROM SValues
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms bind S_2/C_3: SELECT * FROM SValues
2007-09-19 14:10:51.993 LOG: duration: 0.000 ms execute S_2/C_3: SELECT * FROM SValues
20
Thanks
Frédéric
-----Message d'origine-----
De : pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] De la part de Frédéric Houbie
Envoyé : mercredi 19 septembre 2007 13:54
À : pgsql-jdbc@postgresql.org
Objet : [JDBC] Postgres 8.2 and setFetchSize
Hi,
I'm trying to use the setFetchSize method to get back results faster. I'm using PostgreSQL 8.2 under XP. I'm using postgresql-8.2-505.jdbc3.jar driver. I'm connecting to a Postgres on Linux (PostgreSQL 8.2.4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)). I think that the setFetchSize do not work. I've read a lot about the conditions for that to work (autocommit false) but it's not working.
Here is my sample code:
public static void main(String[] args) throws Exception{
Connection con=null;
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String s_server = "jdbc:postgresql://regulus:5432/ignimport" ;
try {
con = DriverManager.getConnection(s_server, "bs", "");
} catch(Exception e)
{
e.printStackTrace();
}
Statement st = con.createStatement();
con.setAutoCommit(false);
st.setFetchSize(Integer.parseInt(args[0]));
System.out.println("FetchSize : " + st.getFetchSize());
String q="SELECT a FROM SValues WHERE Name = 'title'";
long t1 = System.currentTimeMillis();
ResultSet resultSet = st.executeQuery(q);
if (resultSet.next())
{
String s = resultSet.getString(1);
}
long t2 = System.currentTimeMillis();
System.out.println("exec time : " + (t2 - t1));
}
It always take the same time (long time) whatever value I pass to this code for the FetchSize. It is really a problem because I can't use the LIMIT keywords as I don't know the exact number of records I need.
Any advice ?
Thanks
Frédéric Houbie
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
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: fh@ionicsoft.com
Subject: Re: Postgres 8.2 and setFetchSize
In-Reply-To: <95484F7A889A61469885286054F675DD51252A@altarf.ionicsoft.com>
References: <95484F7A889A61469885286054F675DD512526@altarf.ionicsoft.com> <95484F7A889A61469885286054F675DD51252A@altarf.ionicsoft.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