Joep Roebroek wrote:
I had this question, which I didn't really know where to ask, so I
thought to begin at this mailing list.
Very basicly said, I count the rows of a table which had approx 50000
or more rows.
The problem is, there is a notable difference in loading time with
other pages. Is there a technique to estimate the number of rows
instead of exactly couting them? So that it saves loading time.
For example, when you search with google, you get an estimate of the
number of results, how do they do this?
Maybe this is not a question for the PHP Mailing list, but if not
where is a better place to ask this?
Sadly you didn't say which database you are using... so I'll give you an
answer for MySQL... I don't know what other DBs do.
Say you have:
SELECT * FROM table WHERE condition;
You only show the n results but these may be "paged" or offset.
What I would do here is:
SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE condition LIMIT n OFFSET y;
This limits how many results MySQL actually gives you *but* allows you
to know what the full number of results would have been if you hadn't
used LIMIT via a second statement:
SELECT FOUND_ROWS()
Hopefully that solves your issue, but perhaps I've missed what you are
actually trying to do.
Col
Is that the kind of answer you are looking for?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php