title: In MySQL 5, SELECT COUNT(1) FROM table_name is very slow
body: <p>I have a MySQL 5.0 database with a few tables containing over 50M rows. But how do I know this? By running "SELECT COUNT(1) FROM foo", of course. This query on one table containing 58.8M rows took <strong>10 minutes</strong> to complete!</p>
  
  <pre><code>mysql&gt; SELECT COUNT(1) FROM large_table;
  +----------+
  | count(1) |
  +----------+
  | 58778494 | 
  +----------+
  1 row in set (10 min 23.88 sec)
  
  mysql&gt; EXPLAIN SELECT COUNT(1) FROM large_table;
  +----+-------------+-------------------+-------+---------------+----------------------------------------+---------+------+-----------+-------------+
  | id | select_type | table             | type  | possible_keys | key                                    | key_len | ref  | rows      | Extra       |
  +----+-------------+-------------------+-------+---------------+----------------------------------------+---------+------+-----------+-------------+
  |  1 | SIMPLE      | large_table       | index | NULL          | fk_large_table_other_table_id          | 5       | NULL | 167567567 | Using index | 
  +----+-------------+-------------------+-------+---------------+----------------------------------------+---------+------+-----------+-------------+
  1 row in set (0.00 sec)
  
  mysql&gt; DESC large_table;
  +-------------------+---------------------+------+-----+---------+----------------+
  | Field             | Type                | Null | Key | Default | Extra          |
  +-------------------+---------------------+------+-----+---------+----------------+
  | id                | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment | 
  | created_on        | datetime            | YES  |     | NULL    |                | 
  | updated_on        | datetime            | YES  |     | NULL    |                | 
  | other_table_id    | int(11)             | YES  | MUL | NULL    |                | 
  | parent_id         | bigint(20) unsigned | YES  | MUL | NULL    |                | 
  | name              | varchar(255)        | YES  |     | NULL    |                | 
  | property_type     | varchar(64)         | YES  |     | NULL    |                | 
  +-------------------+---------------------+------+-----+---------+----------------+
  7 rows in set (0.00 sec)
  </code></pre>
  
  <p>All of the tables in question are InnoDB.</p>
  
  <p>Any ideas why this is so slow, and how I can speed it up?</p>