Re: MySQL ResultSet - count rows?
- From: Ruud de Koter <nobody@xxxxxxxxxxxx>
- Date: Thu, 13 Dec 2007 09:57:30 +0100
Lew wrote:
Dyreatnews@xxxxxxx wrote:True. I may have gotten carried away as I was writing. What matters is that the double-select solution has its issues. One should be aware of those and decide whether these are acceptable, can be mitigated (as you propose), or are prohibitive.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.
Regards,
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
- MySQL ResultSet - count rows?
- Prev by Date: Re: What does everyone else do for graphically displaying data?
- 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):