mysql 缓存

从mysql4.1版本之后新增的功能。
作用:存储select查询的文本以及相应结果。如果随后收到一个相同的查询,则不再解析和执行查询,而是直接从缓存中得到查询结果。

mysql> show variables like '%query_cache%';
+------------------------------+---------+
| Variable_name                | Value   |
+------------------------------+---------+
| have_query_cache             | YES     |
| query_cache_limit            | 1048576 |
| query_cache_min_res_unit     | 4096    |
| query_cache_size             | 1048576 |
| query_cache_type             | OFF     |
| query_cache_wlock_invalidate | OFF     |
+------------------------------+---------+
6 rows in set (0.00 sec)
变量例子描述
have_query_cacheYES表明服务器在安装时是否配置了告诉缓存
query_cache_limit1048576
query_cache_min_res_unit4096
query_cache_size1048576表明缓存区的大小,单位为MB
query_cache_typeOFF变量从0到2,1或者off(缓存关闭),1或者on(缓存打开,使用SQL_NOCACHE提示的select除外),2或者demand(只带有SQL_CACHE的select语句提供高速缓存)
query_cache_wlock_invalidateOFF

缓存监控

mysql> show status like '%Qcache%';
+-------------------------+---------+
| Variable_name           | Value   |
+-------------------------+---------+
| Qcache_free_blocks      | 1       |
| Qcache_free_memory      | 1031352 |
| Qcache_hits             | 0       |
| Qcache_inserts          | 0       |
| Qcache_lowmem_prunes    | 0       |
| Qcache_not_cached       | 33048   |
| Qcache_queries_in_cache | 0       |
| Qcache_total_blocks     | 1       |
+-------------------------+---------+
8 rows in set (0.00 sec)
Variable_nameValue描述
Qcache_free_blocks1查询缓存中的空闲内存块的数目
Qcache_free_memory1031352查询缓存的空闲内存数
Qcache_hits0缓存采样数数目
Qcache_inserts0被加入到缓存中的查询数目
Qcache_lowmem_prunes0因为缺少内存而被删除的查询数目
Qcache_not_cached33048没有被缓存的查询数目(不能被缓存的,或由于QUERY_CACHE_TYPE)
Qcache_queries_in_cache0在缓存中已注册的查询数目TYPE
Qcache_total_blocks1查询缓存中的块的总数目
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值