Re: ResultSet storing all rows with defaulftFetchSize to 5000 - Mailing list pgsql-jdbc

From Brad DeJong
Subject Re: ResultSet storing all rows with defaulftFetchSize to 5000
Date
Msg-id CAJnrtnwzjFApwFVpyz=Fc7=d_VaZFTyoMrJ3PO_qf5+OWo-p2w@mail.gmail.com
Whole thread Raw
In response to ResultSet storing all rows with defaulftFetchSize to 5000  (Jaime Soler <jaime.soler@gmail.com>)
Responses Re: ResultSet storing all rows with defaulftFetchSize to 5000  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc


On Wed, Feb 7, 2018 at 1:00 PM, Jaime Soler <jaime.soler@gmail.com> wrote:
... ResultSet holdability is HOLD_CURSOR_OVER_COMMIT. ...
And the postgresql comunity jdbc driver 9.4 documentation said:
"... There are a number of restrictions which will make the driver silently fall back to fetch the whole ResultSet ..."


And the statement must be created with a ResultSet holdability of CLOSE_CURSORS_AT_COMMIT - which is not documented. https://github.com/pgjdbc/pgjdbc/pull/1105 submitted to fix that.

The relevant code fragment from org.postgresql.jdbc.PgStatement.java is ...

    // Enable cursor-based resultset if possible.
    if (fetchSize > 0 && !wantsScrollableResultSet() && !connection.getAutoCommit()
        && !wantsHoldableResultSet()) {
      flags |= QueryExecutor.QUERY_FORWARD_CURSOR;
    }

And the fragment from org.postgresql.v3.QueryExecutorImpl.java ...

    boolean usePortal = (flags & QueryExecutor.QUERY_FORWARD_CURSOR) != 0 && !noResults && !noMeta
        && fetchSize > 0 && !describeOnly;

pgsql-jdbc by date:

Previous
From: Jaime Soler
Date:
Subject: ResultSet storing all rows with defaulftFetchSize to 5000
Next
From: Alan Stange
Date:
Subject: setFetchSize() and preferQueryMode incompatible?