Both mysql_num_rows and count(*) can count the total number, which one is better?
or
When to use num_rows and count( * ) respectively
An intuitive comparison
Test data:
Number of items: 139764
Data table size: 500M
Result:
fetch_num_rows time: 35.272329092026
count(*) time: 0.071956872940063
If the number is simply counted, of course it is count(*)
fetch_num_rows must be traversed through the database. The result is less efficient than count(*)