清空mysql 查询缓存

mysql 查询缓存

原文地址:http://blog.600km.xyz/2015/12/14/clear-mysql-query-cache/

在sql调优的过程中,发现原本很慢的一条sql(将近1分钟) 在第二次运行时, 瞬间就完成了(0.04sec)。
这是因为mysql自带的缓存机制,将查询结果进行缓存,如果table数据未发生变化,再次使用同一条sql进行查询时,直接从上次的查询结果缓存中读取数据,而不是重新分析、执行sql。
如果table数据发生变化,所有与之相关的缓存都会被释放刷新,这样就不会出现数据脏读问题。

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.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值