Re: Saving loading time at counting rows

From: Date: Sun, 13 Jul 2008 03:22:04 +0000
Subject: Re: Saving loading time at counting rows
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-276714@lists.php.net to get a copy of this message
At 2:26 AM +0200 7/13/08, 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? regards, Joep
Joep: If it was me and the number of rows were not critical, then I would do it once a day and store that "count" in a table where I needed an approximate number. Then loading that number for the rest of the day would be instant. You don't need a cron job for that, just tie a date to the "count" entry and have each access to it compare the date with current date. If the date is 24 hours since the last update, then that lucky person has to wait a bit longer than most while a count is establish and recorded. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#276714) next »