Re: MySQL ResultSet - count rows?
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Wed, 12 Dec 2007 21:56:14 -0500
Dyreatnews@xxxxxxx wrote:
No. You could execute 'SELECT COUNT(*) ...' first but then you
essentially traverse all the rows twice.
Ruud de Koter wrote:
One should realize that in doing so you are not determining the number of rows at the moment of retrieval, but the number of rows a few moments before the actual retrieval. Whether this is an important distinction depends with the volatility of the table and the use you will make if this number. On any system used by more than one user/process, these numbers *will* be different, sooner or later.
In short: this is not the way to go.
You could wrap the SELECT COUNT(*) and the row SELECT in a transaction, thus guaranteeing at least a consistent view if not a current one.
--
Lew
.
- Follow-Ups:
- Re: MySQL ResultSet - count rows?
- From: Dyreatnews
- Re: MySQL ResultSet - count rows?
- From: Ruud de Koter
- 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
- 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):