From: Maik Wiege <mswiege@gmx.de>
To: pgsql-jdbc@postgresql.org
Subject: get row count from a "cursor resultset"
Date: Wed, 06 Jul 2005 21:19:18 +0200
Message-ID: <42CC2EB6.8020505@gmx.de> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mswiege@gmx.de
Subject: Re: get row count from a "cursor resultset"
In-Reply-To: <42CC2EB6.8020505@gmx.de>
References: <42CC2EB6.8020505@gmx.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox