MySQL Forums
Forum List  »  Performance

Re: resultset rows performance
Posted by: Aftab Khan
Date: September 14, 2012 03:54AM

To obtain row count (i.e. COUNT(*)), include a SQL_CALC_FOUND_ROWS option in the SELECT statement, and then invoke FOUND_ROWS() afterward:
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
    -> WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();
OR
mysql> SET @rows = FOUND_ROWS();
If you are using SELECT SQL_CALC_FOUND_ROWS, MySQL must calculate how many rows are in the full result set. However, this is faster than running the query again without LIMIT, because the result set need not be sent to the client.

http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

Options: ReplyQuote


Subject
Views
Written By
Posted
2560
September 14, 2012 02:16AM
Re: resultset rows performance
1156
September 14, 2012 03:54AM
1120
September 14, 2012 07:49AM
1047
September 14, 2012 10:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.