title: MySQL get the number of rows in an innodb table
body: <p>I have a table using innodb. I know the table has roughly 89 million rows. Using</p>
  
  <pre><code>SELECT COUNT(*) FROM table;
  </code></pre>
  
  <p>takes about five minutes to run. I know that innodb is not optimized for unconditional COUNT(*) queries. How can I restructure the query to give me a count faster? Would just adding WHERE 1=1 work, or do I need to query a specific field?</p>
  
  <p>I know I can get the approximate number of rows using SHOW TABLE STATUS, but I want to get the value in a PHP script, and it seems like there is a lot to dig through using that method.</p>