Re: JDBC: Fast way to find the number of rows in a ResultSet?
- From: "joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx>
- Date: 26 May 2007 10:14:55 -0700
On May 25, 3:11 pm, Philipp Taprogge <Philipp.Tapro...@xxxxxxx> wrote:
Hi!
Thus spake Arne Vajhøj on 05/24/2007 01:53 AM:
To do that the ResultSet would likely need to be scrollable
and that will cause many JDBC drivers to read all data
into memory. So this solution works best with small data.
True, but that's a limitation to JDBC. If you can't do a SELECT COUNT(*) far
some reason, then this is AFAICS your only option. Using last() is just
prettier and could be a little bit better performance-wise if the driver is
optimized for it.
Regards,
Phil
The lion's share of the work involved in a driver implementing last()
is simply the reading in (and maybe having to ask for) the data, and
caching it in memory if it's a scrollable result set. A loop of
next() calls won't be any different in performance. And again, if
someone else adds or deletes rows in between your receiving the
results of you "select count(*)" and when you run your actual query
for the data, then you will get a different number of rows than your
count anyway.
Joe Weinstein at BEA Systems
.
- References:
- JDBC: Fast way to find the number of rows in a ResultSet?
- From: Ronald Fischer
- Re: JDBC: Fast way to find the number of rows in a ResultSet?
- From: Philipp Taprogge
- Re: JDBC: Fast way to find the number of rows in a ResultSet?
- From: Arne Vajhøj
- Re: JDBC: Fast way to find the number of rows in a ResultSet?
- From: Philipp Taprogge
- JDBC: Fast way to find the number of rows in a ResultSet?
- Prev by Date: Re: JDBC: Fast way to find the number of rows in a ResultSet?
- Next by Date: Re: Slow performance with SQL and stmt.executeUpdate()
- Previous by thread: Re: JDBC: Fast way to find the number of rows in a ResultSet?
- Next by thread: Re: JDBC: Fast way to find the number of rows in a ResultSet?
- Index(es):
Relevant Pages
|
|