Re: MySQL ResultSet - count rows?
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Tue, 11 Dec 2007 19:09:52 -0500
Lew wrote:
Arne Vajhøj wrote:Dyreatnews@xxxxxxx wrote:On the other hand; if you're using a scrollable result set, you can loop
over it to find the size,
You don't even need to loop.
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT * FROM T1");
rs.last();
int n = rs.getRow();
rs.first();
But I would never use that construct.
Arne: What are the dangers of that construct?
I'm guessing that it's the overhead of going first / last / first on large datasets.
Most (maybe all) drivers will implement that scrollable
feature by reading all data into memory.
medium data size => bad performance
large and huge data => OutOfMemoryError
Arne
.
- References:
- MySQL ResultSet - count rows?
- From: Christoph
- Re: MySQL ResultSet - count rows?
- From: Sabine Dinis Blochberger
- Re: MySQL ResultSet - count rows?
- From: Christoph
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- Re: MySQL ResultSet - count rows?
- From: Arne Vajhøj
- Re: MySQL ResultSet - count rows?
- From: Lew
- MySQL ResultSet - count rows?
- Prev by Date: Re: What does everyone else do for graphically displaying data?
- Next by Date: Re: What does everyone else do for graphically displaying data?
- Previous by thread: Re: MySQL ResultSet - count rows?
- Next by thread: Re: MySQL ResultSet - count rows?
- Index(es):
Relevant Pages
|