RE: [PHP] query totalrows + thousands of results slow in pagination function

From: Date: Tue, 20 May 2003 02:43:20 +0000
Subject: RE: [PHP] query totalrows + thousands of results slow in pagination function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-148242@lists.php.net to get a copy of this message
> hi there, i have a pagination function which works ok with small > resultsets > but noticed a massive change in performance when i used it against > thousands of results , basically there is two queries one to get the > mysql_num_rows total results and the other to append a limit clause to the > query , although i have found this to be slow as it is taking a bit to get > the totalrows first to the tune of 15 secs , it seems to be buffering it > aswell which i dont want , is there a good ideal way to improve this ? > > i have tried these SQL_CALC_FOUND_ROWS , count(*) , mysql_unbuffered_query > with no luck , the setting on the server has cache to ON instead of demand > so SQL_NO_CACHE doesnt seem to work , sorry if this maybe off topic but > mysql_num_rows is slow You should be using COUNT(*) to get the total number and then your LIMIT query. This is going to be the fastest (haven't tried SQL_CALC_FOUND_ROWS, though). I don't know why this isn't the case for you, though. Maybe it's just a table design issue? Are you doing any joins? ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#148242) next »