title: Check if MySQL Table is empty: COUNT(*) is zero vs. LIMIT(0,1) has a result?
body: <p>This is a simple question about efficiency specifically related to the MySQL implementation. I want to just check if a table is empty (and if it is empty, populate it with the default data). Would it be best to use a statement like <code>SELECT COUNT(*) FROM `table`</code> and then compare to 0, or would it be better to do a statement like <code>SELECT `id` FROM `table` LIMIT 0,1</code> then check if any results were returned (the result set has next)?</p>
  
  <p>Although I need this for a project I am working on, I am also interested in how MySQL works with those two statements and whether the reason people seem to suggest using <code>COUNT(*)</code> is because the result is cached or whether it actually goes through every row and adds to a count as it would intuitively seem to me.</p>