php - Using count(*) vs num_rows -


to number of rows in result set there 2 ways:

  1. is use query count

    $query="select count(*) count some_table type='t1'";

    and retrieving value of count.

  2. is getting count via num_rows(), in php.

so 1 better performance wise?

if goal count rows, use count(*). num_rows ordinarily (in experience) used confirm more 0 rows returned , continue on in case. take mysql longer read out many selected rows compared aggregation on count if query takes same amount of time.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -