Re: RE : Nmber of rows in a ResultSet

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: RE : Nmber of rows in a ResultSet
Дата
Msg-id Pine.LNX.4.33.0401090454510.6759-100000@leary.csoft.net
обсуждение исходный текст
Ответ на RE : Nmber of rows in a ResultSet  ("Xavier Bugaud" <xavier.bugaud@gloptv.com>)
Список pgsql-jdbc

On Fri, 9 Jan 2004, Xavier Bugaud wrote:

> > On Fri, 9 Jan 2004, Kris Jurka wrote:
> >
> > > In the last JDBC drivers, is there a means to get the number of rows
> > > directly (without using 'SELECT COUNT(*)' or
> > 'rs.last();rs.getrow();') ?
> >
> > I don't see what's so wrong with rs.last() and rs.getRow().
> >
>
> Thank you for the response.
>
> What is wrong with rs.last() and rs.getRow() is
> - it requires scrollable cursors in order to get back to the first row
> - it will certainly slow down the operation in case of huge amount of
> rows (I don't known how the Postgres driver handle that, so maybe this
> is wrong... I hope so)

In earlier versions of pg every row of a query was retrieved before any
user processing could occur.  This meant that by default all ResultSets
were scrollable and rs.last() was pretty much free at that point.

Newer versions allow partial fetches from ResultSets via a cursor.  This
only works on non-scrollable results and these cannot tell how many rows
are going to be in the final result until they have fetched them all.

This leaves you no worse of than you were before.  You have the option of
retrieving all rows and counting them that way at the same expense you had
in previous versions.

Kris Jurka


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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: [BUG] - Invalid UNICODE character sequence found
Следующее
От: Csaba Nagy
Дата:
Сообщение: Re: [BUG] - Invalid UNICODE character sequence found