title: best practice to count record in MySQL + PHP
body: <p>I want to check weather number of record > 15 for a condition. </p>
  
  <p>What is best practice to speed up the query?</p>
  
  <p>1)</p>
  
  <pre><code>$query="SELECT `id` FROM `table` WHERE `name`='$name' AND `usage` &gt; '$limit'";
  $result=mysql_query($query);       
  if(mysql_num_rows($result) &gt;15) 
  {
      //do task
  
  }
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>$query="SELECT COUNT(1) AS 'cnt' FROM `table` WHERE `name`='$name' AND `usage` &gt; '$limit'";
  
  $result=mysql_query($query); 
  $row = mysql_fetch_assoc($result);
  
  if($row['cnt'] &gt;15) 
  {
      //do task
  
  }
  </code></pre>
  
  <p>3) any other best way?</p>