<
>

MySQL高速缓存启动方法及参数详解(query_cache_size)

2019-01-05 10:02:29 来源:易采站长站 作者:丽君


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             | 134217728 |
| query_cache_type             | ON        |
| query_cache_wlock_invalidate | OFF       |
+——————————+———–+
6 rows in set (0.00 sec)

主要看query_cache_size和query_cache_type的值是否跟我们设的一致:

这里query_cache_size的值是134217728,我们设置的是128M,实际是一样的,只是单位不同,可以自己换算下:134217728 = 128*1024*1024。

query_cache_type设置为1,显示为ON,这个前面已经说过了。

总之,看到上边的显示表示设置正确,但是在实际的查询中是否能够缓存查询,还需要手动测试下,我们可以通过show status like ‘%Qcache%';语句来测试,现在我们开启了查询缓存功能,在执行查询前,我们先看看相关参数的值:


mysql> show status like ‘%Qcache%';
+————————-+———–+
| Variable_name           | Value     |
+————————-+———–+
| Qcache_free_blocks      | 1         |
| Qcache_free_memory      | 134208800 |
| Qcache_hits             | 0         |
| Qcache_inserts          | 0         |
| Qcache_lowmem_prunes    | 0         |
| Qcache_not_cached       | 2         |
| Qcache_queries_in_cache | 0         |
| Qcache_total_blocks     | 1         |
+————————-+———–+
8 rows in set (0.00 sec)
暂时禁止评论

微信扫一扫

易采站长站微信账号