Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 685649F9B4A for ; Wed, 19 Sep 2007 09:05:50 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 36090-08 for ; Wed, 19 Sep 2007 09:05:40 -0300 (ADT) X-Greylist: delayed 00:12:12.126323 by SQLgrey-1.7.5 Received: from mail.ionicsoft.com (mail.ionicsoft.com [81.188.4.2]) by postgresql.org (Postfix) with ESMTP id DF2659F9B95 for ; Wed, 19 Sep 2007 09:05:44 -0300 (ADT) Content-class: urn:content-classes:message Subject: Postgres 8.2 and setFetchSize MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 19 Sep 2007 13:53:31 +0200 Message-ID: <95484F7A889A61469885286054F675DD512526@altarf.ionicsoft.com> X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Postgres 8.2 and setFetchSize Thread-Index: Acf6s7Kpe8qKqwUsRcaRZT/6FA9m/w== From: =?iso-8859-1?Q?Fr=E9d=E9ric_Houbie?= To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/95 X-Sequence-Number: 17517 Hi,=20 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=3Dnull; try { Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } String s_server =3D = "jdbc:postgresql://regulus:5432/ignimport" ; try { con =3D DriverManager.getConnection(s_server, "bs", = ""); } catch(Exception e) { e.printStackTrace(); } Statement st =3D con.createStatement(); con.setAutoCommit(false); st.setFetchSize(Integer.parseInt(args[0])); System.out.println("FetchSize : " + st.getFetchSize()); String q=3D"SELECT a FROM SValues WHERE Name =3D 'title'"; long t1 =3D System.currentTimeMillis(); ResultSet resultSet =3D st.executeQuery(q); if (resultSet.next()) { String s =3D resultSet.getString(1); } long t2 =3D 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 ?=20 Thanks =20 =20 Fr=E9d=E9ric Houbie =20