very large result sets and ResultSet.relative() to jump to a desired offset

Поиск
Список
Период
Сортировка
От Matt Magoffin
Тема very large result sets and ResultSet.relative() to jump to a desired offset
Дата
Msg-id 50687.192.168.1.106.1222221378.squirrel@msqr.us
обсуждение исходный текст
Ответы Re: very large result sets and ResultSet.relative() to jump to a desired offset  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-jdbc
When executing a large query, I am to understand that for server-side
cursors to be used (so to not run out of memory by loading the entire
result set into memory at once) I need to specify
ResultSet.TYPE_FORWARD_ONLY and then stmt.setFetchSize(x).

However, I'd like to be able to jump to the Xth result and display only Y
results, i.e. support pages of results and allow jumping to arbitrary
pages and thus arbitrary offsets in the result query. In code I used to do
set ResultSet.TYPE_SCROLL_INSENSITIVE, stmt.setFetchSize(Y), and then
rs.relative(X) where stmt is a Statement and rs is a ResultSet.

This causes the entire result set to get loaded into memory. To use a
FORWARD_ONLY result, I can't use ResultSet.relative() anymore. Is there
any alternative, other than perhaps calling ResultSet.next() X times
before returning the results? For very large results (millions of rows)
this seems like a slow solution, as I assume that all results will
actually get passed through JDBC just to jump to the desired row.

-- m@




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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: stored procedure returning result set.
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: very large result sets and ResultSet.relative() to jump to a desired offset