get row count from a "cursor resultset"

From: Maik Wiege <mswiege(at)gmx(dot)de>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: get row count from a "cursor resultset"
Date: 2005-07-06 19:19:18
Message-ID: 42CC2EB6.8020505@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello!
I'm querying my database and sometimes get a very big resultset back, so
I needed to use a resultset with a cursor to avoid a OutOfMemoryError.

Now, because I have to use a TYPE_FORWARD_ONLY resultset for that, I can
not use the result.last() function anymore to retrieve the amount of
rows the query returns.

The query is a little bit complicated and that for can take some time,
so I don't want to do the "SELECT COUNT(*) FROM (SELECT...)" afterward,
what would result in doing the query twice and there for would double
the time needed.

I didn't find a solution for this, but there must be, because the
pgAdmin III - tool does this. After starting the query in the SQL-Dialog
it asks wether to retrieve just the first 100 results or all results
displaying the corect amount of found rows. Or is this just not possible
with jdbc.

Thanks for any help

Maik

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2005-07-06 22:27:26 Re: get row count from a "cursor resultset"
Previous Message Dave Cramer 2005-07-06 02:30:40 Re: JDBCCTS issues