Re: MySQL ResultSet - count rows?
- From: Ruud de Koter <nobody@xxxxxxxxxxxx>
- Date: Thu, 13 Dec 2007 22:28:01 +0100
Arne Vajhøj wrote:
Lew wrote:To make this decision a real dilemma, using serializable transactions will have 'interesting' consequences for resource contention, hence timeouts and (percieved) performance in any multi-user environment. This really is something to consider carefully.Dyreatnews@xxxxxxx wrote:Ruud is making a very good point. I've just been told that the the
SELECT COUNT(*) approach will only be guaranteed to work if you execute
both SELECTs in a single transaction AND use SERIALIZABLE isolation
level. Even at REPEATABLE READ you may see new rows added since the
previous select, (but all rows counted will have the same value
throughout the transaction).
You won't "see" those new rows added until after the transaction completes.
You will.
user 1 - SELECT COUNT(*)
user 2 - INSERT
user 1 - SELECT
Only SERIALIZABLE will prevent this.
Arne
Re-reading the original post, I saw that this is about writing a ResultSet's data into an Array. It 'd be much wiser to use some subtype of List in this case, and just avoid knowing the number of rows in advance. I think one of the other posters already suggested this. Doing so would keep one away from this minefield.
Ruud.
.
- References:
- MySQL ResultSet - count rows?
- From: Christoph
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- Re: MySQL ResultSet - count rows?
- From: Ruud de Koter
- Re: MySQL ResultSet - count rows?
- From: Lew
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- Re: MySQL ResultSet - count rows?
- From: Lew
- Re: MySQL ResultSet - count rows?
- From: Arne Vajhøj
- MySQL ResultSet - count rows?
- Prev by Date: Re: MySQL ResultSet - count rows?
- Next by Date: Re: MySQL ResultSet - count rows?
- Previous by thread: Re: MySQL ResultSet - count rows?
- Next by thread: Re: MySQL ResultSet - count rows?
- Index(es):
Relevant Pages
|