查询缓存设置情况
show variables like 'query_cache%';
# 配置说明
query_cache_limit:单个查询能够使用的缓冲区大小
query_cache_size:缓存空间大小,单位是字节
query_cache_type:是否有开启缓存
![c4f7499e5671a5262644d9c46eea70b2.png](https://img-blog.csdnimg.cn/img_convert/c4f7499e5671a5262644d9c46eea70b2.png)
配置查询缓存
在mysql配置文件中添加如下的代码后,重记mysql服务,使用了查询缓存。
query_cache_limit = 1M 单条sql缓存容量
query_cache_size = 16M mysql开的缓存的总大小
query_cache_type = 1
![dfa57def07e051f661393be5afbc4a4e.png](https://img-blog.csdnimg.cn/img_convert/dfa57def07e051f661393be5afbc4a4e.png)
一定重启mysql服务,执行sql查询语句,同样的sql语句第2句就会使用到查询缓存,但要注意:区分大小写。如果第一此查询数据的是大写,那么第二次也要进行大写才会请求缓存里面的数据