You said: -------------------------- is there a way to calculate the number of rows retrieved by a mysql query, without actually performing it?
I want to make a paginated result like in most search engines, and for that I need to display the number of pages the result would have, but I do not want to actually retrieve all the rows to be able to count them, because this is a loss of performance, in particular if the result set retrieves 100000 rows and 100 people make a search; this would end in 10000 x 100 rows just to say how many pages the result will have, I think there must be a better way to do it, isn't it? ----------------------------------------- If you add SQL_CALC_FOUND_ROWS to the SELECT statement with LIMIT (as explained at http://www.mysql.com/doc/S/E/SELECT.html ) you can then use the FOUND_ROWS() function described at http://www.mysql.com/doc/M/i/Miscellaneous_functions.html to return the numer of rows that would have been returned without a LIMIT statement. This statement is only available from MySQL 4.0, and presumably depends for its performance on the V4 query cacheing (I.e. as you repeatedly re-query with different LIMITs, it doen't redo the select because it recognises a familar request). Alec Cawley --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php