title: SQL Performance - SELECT COUNT vs SELECT id with LIMIT 1
body: <p>having a mysql database with innodb and I want to find the fastest way to check whether a row exist.</p>
  
  <p>So is it faster to do:</p>
  
  <pre><code>    $sql5 = "SELECT id, value FROM pc_taxes WHERE id = :taxId AND client_id = :clientID LIMIT 1";
              $stmt5 = getaccessdata::getInstance()-&gt;prepare($sql5);
              $stmt5-&gt;bindValue(':clientID', $client_id, PDO::PARAM_INT);
              $stmt5-&gt;bindValue(':taxId', $taxID, PDO::PARAM_INT);
  
              try {
                  $stmt5-&gt;execute();
                  $req5 = $stmt5-&gt;fetchAll(PDO::FETCH_ASSOC);
                  $countTaxVal = 0;
                  foreach ($req5 as $r5) {
                      $countTaxVal++;
                  }
              } catch (Exception $e) {
  
              }
  
  if($countTaxVal&gt;0){
  $rowExist=true;
  }
  </code></pre>
  
  <p>or is this version faster on very large records:</p>
  
  <pre><code>$sql5 = "SELECT COUNT(*) FROM pc_taxes WHERE id = :taxId AND client_id = :clientID LIMIT 1";
              $stmt5 = getaccessdata::getInstance()-&gt;prepare($sql5);
              $stmt5-&gt;bindValue(':clientID', $client_id, PDO::PARAM_INT);
              $stmt5-&gt;bindValue(':taxId', $taxID, PDO::PARAM_INT);
  
  numRows =0;
              try {
                  $stmt5-&gt;execute();
                  $numRows = $stmt5-&gt;fetchColumn();
  
  
              } catch (Exception $e) {
  
              }
  
  if($numRows &gt;0){
  $rowExist=true;
  }
  </code></pre>
  
  <p>Thanks for your advices.</p>