就比如我查询id = 1的记录用时 10秒
第二次查询缩短到 1秒甚至更少

解决方案 »

  1.   

    正解。当你关闭SQL服务,再启动时,执行时时间又长了。
      

  2.   

    http://dev.mysql.com/doc/refman/5.1/en/query-cache.html7.5.5. The MySQL Query Cache
    The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again. The query cache is shared among sessions, so a result set generated by one client can be sent in response to the same query issued by another client. 
      

  3.   

    基本上所有的数据库都有缓存,即第一次慢,第二次执行相同的SQL语句,速度快,除非你强制不使用缓存
      

  4.   

    mysql会自动缓存? 是的,MySQL会对查询结果缓存。这样以利下次相同的查询语句的执行速度。