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

javascript - CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any -

codeigniter - Fatal error: Call to undefined function lang() in CI Merchant using CardSave -

python - Received unregistered task using Celery with Django -