SQL_NO_CACHE does not work

前端 未结 4 692
情话喂你
情话喂你 2020-12-08 02:55

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:

mysql> select count(*) from `deal         


        
相关标签:
4条回答
  • 2020-12-08 03:05

    I was under the impression that including any sort of SQL function that is calculated in the current runtime would not cache. Have you tried doing something like the following?

    select count(*), now() from `deal_expired` where `site`=8&&`area`=122 && endtime<1310444996056;
    
    0 讨论(0)
  • 2020-12-08 03:18

    The first query should use SQL_NO_CACHE to tell MySQL not to put the result into the cache. The second query uses the cache and the tells MySQL not to cache the result of that query, which does nothing.

    tl;dr - Reverse your queries.

    0 讨论(0)
  • 2020-12-08 03:20

    The answer to "How can I get the same SQL run-time?" is - you cannot. If your query reads some rows, they are cached, dependent on the storage engine in use, those rows are either in OS cache (myisam), or in buffer pool (innodb). If rows are cached, running the same query second time is much faster, because MySQL does not have to read from the disk.

    0 讨论(0)
  • 2020-12-08 03:24
    1. see: http://forums.mysql.com/read.php?24,225286,225468#msg-225468
    2. you could try RESET QUERY CACHE (you need the RELOAD privilege) although having just read the link above this will probably not work either :(
    0 讨论(0)
提交回复
热议问题