Re: MySQL ResultSet - count rows?
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Thu, 13 Dec 2007 10:12:55 -0500
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.
Even at "read uncommitted" isolation you likely will be fine. It depends on whether you need to see rows added during the transaction or not, i.e., on whether you want the values to represent the db state at the end of your transaction, or if it's sufficient to see the state at the beginning of the transaction.
After all, rows could be added a nanosecond after your transaction, too, and you wouldn't know it.
There's nothing wrong with seeing the db state as of transaction start, in most cases. There will *always* be latency in your queries. The point of the transaction is that it gives you a consistent view of the data, and that's almost always sufficient.
Bear in mind that not all configurations of MySQL tables support transactions.
--
Lew
.
- Follow-Ups:
- Re: MySQL ResultSet - count rows?
- From: Arne Vajhøj
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- Re: MySQL ResultSet - count rows?
- 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
- MySQL ResultSet - count rows?
- Prev by Date: Java Requierment
- 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
|
|