Postgres 8.2 and setFetchSize

Поиск
Список
Период
Сортировка
От Frédéric Houbie
Тема Postgres 8.2 and setFetchSize
Дата
Msg-id 95484F7A889A61469885286054F675DD512526@altarf.ionicsoft.com
обсуждение исходный текст
Ответы Re: Postgres 8.2 and setFetchSize  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-jdbc
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.jardriver. I'm connecting to a Postgres on Linux (PostgreSQL 8.2.4 on i686-pc-linux-gnu,
compiledby GCC gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)). I think that the setFetchSize do not work.
I'veread 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
becauseI 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


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: AbstractJdbc2Connection.java getObject(String type, String value)
Следующее
От: Frédéric Houbie
Дата:
Сообщение: Re: Postgres 8.2 and setFetchSize