title: What's the most efficient way to check the presence of a row in a table?
body: <p>Say I want to check if a record in a MySQL table exists. I'd run a query, check the number of rows returned. If 0 rows do this, otherwise do that.</p>
  
  <pre><code>SELECT * FROM table WHERE id=5
  SELECT id FROM table WHERE id=5
  </code></pre>
  
  <p>Is there any difference at all between these two queries? Is effort spent in returning every column, or is effort spent in filtering out the columns we don't care about?</p>
  
  <pre><code>SELECT COUNT(*) FROM table WHERE id=5
  </code></pre>
  
  <p>Is a whole new question. Would the server grab all the values and then count the values (harder than usual), or would it not bother grabbing anything and just increment a variable each time it finds a match (easier than usual)?</p>
  
  <p>I think I'm making a lot of false assumptions about how MySQL works, but that's the meat of the question! Where am I wrong? Educate me, Stack Overflow!</p>