title: SQL_NO_CACHE does not work
body: <p>The first time I run this sql, needs 39 seconds,when I run again and increase SQL_NO_CACHE,does not seem to take effect:</p>
  
  <pre><code>mysql&gt; select count(*) from `deal_expired` where `site`=8&amp;&amp;`area`=122 &amp;&amp; 
  endtime&lt;1310444996056;
  +----------+
  | count(*) |
  +----------+
  |      497 |
  +----------+
  1 row in set (39.55 sec)
  
  mysql&gt; select SQL_NO_CACHE count(*) from `deal_expired` where `site`=8&amp;&amp;`area`=
  122 &amp;&amp; endtime&lt;1310444996056;
  +----------+
  | count(*) |
  +----------+
  |      497 |
  +----------+
  1 row in set (0.16 sec)
  </code></pre>
  
  <p>I tried a variety of methods,  <a href="http://www.issociate.de/board/post/493985/SQL_NO_CACHE.html" rel="noreferrer">here</a></p>
  
  <p>and even restart the mysql server or change table name, but I still can not let 39 seconds run this SQL</p>
  
  <p>I replaced another SQL, and an increase in the first run on SQL_NO_CACHE, the problem is the same:</p>
  
  <pre><code>mysql&gt; select SQL_NO_CACHE count(*) from `deal_expired` where `site`=25&amp;&amp;`area`=
  134 &amp;&amp; endtime&lt;1310483196227;
  +----------+
  | count(*) |
  +----------+
  |      315 |
  +----------+
  1 row in set (2.17 sec)
  
  mysql&gt; select SQL_NO_CACHE count(*) from `deal_expired` where `site`=25&amp;&amp;`area`=
  134 &amp;&amp; endtime&lt;1310483196227;
  +----------+
  | count(*) |
  +----------+
  |      315 |
  +----------+
  1 row in set (0.01 sec)
  </code></pre>
  
  <p>What is the reason?
  How can I get the same SQL run-time?</p>
  
  <p>I want to find a way to optimize this SQL to perform 39 seconds</p>
  
  <p>BTW: <code>RESET QUERY CACHE</code> <code>FLUSH QUERY CACHE</code> <code>FLUSH TABLES</code> <code>SET SESSION query_cache_type=off</code> does not work</p>
  
  <p>mysql state cache has been closed:</p>
  
  <pre><code>mysql&gt; SHOW STATUS LIKE "Qcache%";
  +-------------------------+-------+
  | Variable_name           | Value |
  +-------------------------+-------+
  | Qcache_free_blocks      | 0     |
  | Qcache_free_memory      | 0     |
  | Qcache_hits             | 0     |
  | Qcache_inserts          | 0     |
  | Qcache_lowmem_prunes    | 0     |
  | Qcache_not_cached       | 0     |
  | Qcache_queries_in_cache | 0     |
  | Qcache_total_blocks     | 0     |
  +-------------------------+-------+
  8 rows in set (0.04 sec)
  
  mysql&gt; select count(*) from `deal_expired` where `site`=25&amp;&amp;`area`=134 &amp;&amp; endtime&lt;1310
  483196227;
  +----------+
  | count(*) |
  +----------+
  |      315 |
  +----------+
  1 row in set (0.01 sec)
  
  mysql&gt; SHOW STATUS LIKE "Qcache%";
  +-------------------------+-------+
  | Variable_name           | Value |
  +-------------------------+-------+
  | Qcache_free_blocks      | 0     |
  | Qcache_free_memory      | 0     |
  | Qcache_hits             | 0     |
  | Qcache_inserts          | 0     |
  | Qcache_lowmem_prunes    | 0     |
  | Qcache_not_cached       | 0     |
  | Qcache_queries_in_cache | 0     |
  | Qcache_total_blocks     | 0     |
  +-------------------------+-------+
  8 rows in set (0.00 sec)
  </code></pre>
  
  <hr>
  
  <p>explan this SQL,used site+endtime composite index(named site_endtime):</p>
  
  <pre><code>mysql&gt; explain select count(*) from `deal_expired` where `site`=8&amp;&amp;`area`=122 &amp;&amp; endti
  me&lt;1310444996056;
  +--------+------+-------------------------------+--------------+---------+------
  -+------+-------------+
  | table  | type | possible_keys                 | key          | key_len | ref
   | rows | Extra       |
  +--------+------+-------------------------------+--------------+---------+------
  -+------+-------------+
  | deal_expired | ref  | name,url,endtime,site_endtime | site_endtime |       4 | const
   |  353 | Using where |
  +--------+------+-------------------------------+--------------+---------+------
  -+------+-------------+
  1 row in set (0.00 sec)
  </code></pre>