I want the quickest(least resource hungry) way of getting the number of specific rows from a large table. E.g I want to retrieve the number of entries by a specific username.
What would be the best method? To use COUNT or just SELECT num_rows?
Method 1:
-------------
$query = "SELECT COUNT(usrname) AS usrname FROM table WHERE usrname='$usrname' ";
$res = mysql_query($query) or die(mysql_error());
$array = mysql_fetch_array($res, MYSQL_ASSOC);
$count = $array['usrname'];
Method 2:
-------------
$query = "SELECT usrname FROM table WHERE usrname='$usrname' ";
$res = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($res);
Personally I think method 2 would be quicker but I read alot about using count() to speed things up.
Thanks!