Using count(*) vs num_rows
mysql, php
Solution
If your goal is to actually count the rows, use `COUNT(*)`. `num_rows` is ordinarily (in my experience) only used to confirm that more than zero rows were returned and continue on in that case. It will probably take MySQL longer to read out many selected rows compared to the aggregation on `COUNT` too even if the query itself takes the same amount of time.
Problem
To get number of rows in result set there are two ways: Is to use query to get count `$query="Select count(*) as count from some_table where type='t1'";` and then retrieving the value of count. Is getting count via num_rows(), in php. so which one is better performance wise?