title: Optimize COUNT(*) with MATCH ... AGAINST
body: <p>I am using <code>COUNT(*)</code> with <code>MATCH() ... AGAINST()</code>. My specific query is as follows:</p>
  
  <pre><code>SELECT COUNT(*) FROM `source_code` WHERE MATCH(`html`) AGAINST ('title');
  </code></pre>
  
  <p>I get results after a few seconds:</p>
  
  <pre><code>+----------+
  | count(*) |
  +----------+
  |    17346 |
  +----------+
  1 row in set (16.30 sec)
  </code></pre>
  
  <p>After running the query multiple times, the query always takes around 16 seconds to complete.</p>
  
  <p>Is there any way to speed up this query? Why isn't query cache caching the results of this query?</p>
  
  <p>In case it's helpful, here is the <code>EXPLAIN</code> and <code>CREATE TABLE</code> statements:</p>
  
  <pre><code>EXPLAIN SELECT COUNT(*) FROM `source_code` WHERE MATCH(`html_w`) AGAINST ('title');
  +----+-------------+-------------+----------+---------------+--------+---------+------+------+-------------+
  | id | select_type | table       | type     | possible_keys | key    | key_len | ref  | rows | Extra       |
  +----+-------------+-------------+----------+---------------+--------+---------+------+------+-------------+
  |  1 | SIMPLE      | source_code | fulltext | html          | html   | 0       |      |    1 | Using where |
  +----+-------------+-------------+----------+---------------+--------+---------+------+------+-------------+
  </code></pre>
  
  <p>Looks like the index is being used. (Maybe the overhead is that the query is still <code>Using where</code>? Is it normal for <code>key_len</code> to be 0?)</p>
  
  <pre><code>SHOW CREATE TABLE `source_code`;
  CREATE TABLE `source_code` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `url` varchar(255) NOT NULL,
    `domain` varchar(255) DEFAULT NULL,
    `title` varchar(255) DEFAULT NULL,
    `html` longtext,
    `crawled` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `url` (`url`),
    KEY `crawled` (`crawled`),
    KEY `domain` (`domain`),
    FULLTEXT KEY `html` (`html`)
  ) ENGINE=MyISAM AUTO_INCREMENT=78707 DEFAULT CHARSET=latin1
  </code></pre>
  
  <p>Nothing too crazy in the <code>CREATE TABLE</code> statement.</p>