Skip site navigation (1) Skip section navigation (2)

Postgres 8.2 and setFetchSize

From: Frédéric Houbie <fh(at)ionicsoft(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Postgres 8.2 and setFetchSize
Date: 2007-09-19 11:53:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

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 {
            } catch (ClassNotFoundException e) {

            String s_server = "jdbc:postgresql://regulus:5432/ignimport" ;
            try {
                 con = DriverManager.getConnection(s_server, "bs", "");
            } catch(Exception e)
        Statement st = con.createStatement();
        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 (
            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 ? 


Frédéric Houbie


pgsql-jdbc by date

Next:From: Frédéric HoubieDate: 2007-09-19 12:12:13
Subject: Re: Postgres 8.2 and setFetchSize
Previous:From: Kris JurkaDate: 2007-09-18 22:47:25
Subject: Re: getObject(String type, String value)

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group