I wasn't sure if it recounted the rows, or if after it retrieved the whole result set, it only grabbed the total post query?
views:
51answers:
2
A:
Quoting the manual literally, it “retrieves the number of rows from a result set”. It obviously doesn't run a second query if that's your question (not sure what you mean by “recount all the rows”).
Arthur Reutenauer
2009-10-06 17:28:40
+1
A:
when you run a statement, mysql sends the row count in the header. so no, the query is not re-run to get the count.
this has an interesting implication for queries with LIMIT. mysql_num_rows() returns the number of rows returned after LIMIT is applied. if you use the SQL_CALC_FOUND_ROWS keyword in your SELECT statement, then mysql_num_rows() returns the number of rows that would have been returned if LIMIT were not used. this is helpful for paging.
longneck
2009-10-06 17:31:39