日期:2011-01-25 22:43:00 来源:本站整理
<b>MySQL 查询缓存的实际利用代码示例</b>[MySQL防范]
本文“<b>MySQL 查询缓存的实际利用代码示例</b>[MySQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
以下的文章主要介绍的是MySQL 查询缓存的实际利用代码以及查看MySQL 查询缓存的大小 ,碎片整理,排除缓存以及监督MySQL 查询缓存性能的相关内容的描写,以下就是具体内容的描写,但愿在你此后的学习中会有所帮忙.
- MySQL> select @@query_cache_type;
- +--------------------+
- | @@query_cache_type |
- +--------------------+
- | ON |
- +--------------------+
- MySQL> set query_cache_type=off;
- MySQL> set query_cache_type=on;
- MySQL>
- MySQL> select sql_cache id, title, body from article;
- MySQL> select sql_no_cache id, title, body from article;
- MySQL> show variables like 'have_query_cache';
- +------------------+-------+
- | Variable_name | Value |
- +------------------+-------+
- | have_query_cache | YES |
- +------------------+-------+
- 1 row in set (0.00 sec)
查看MySQL 查询缓存的大小
- MySQL> select @@global.query_cache_size;
- +---------------------------+
- | @@global.query_cache_size |
- +---------------------------+
- | 16777216 |
- +---------------------------+
- 1 row in set (0.00 sec)
- MySQL> select @@query_cache_size;
- +--------------------+
- | @@query_cache_size |
- +--------------------+
- | 16777216 |
- +--------------------+
- 1 row in set (0.00 sec)
查看最大缓存后果,假如后果集大于该数,不缓存.
- MySQL> select @@global.query_cache_limit;
- +----------------------------+
- | @@global.query_cache_limit |
- +----------------------------+
- | 1048576 |
- +----------------------------+
- 1 row in set (0.00 sec)
碎片整理
- MySQL> flush query cache
- -> ;
- Query OK, 0 rows affected (0.00 sec)
排除缓存
- MySQL> reset query cache
- -> ;
- Query OK, 0 rows affected (0.00 sec)
监督MySQL 查询缓存性能:
- MySQL> flush tables;
- Query OK, 0 rows affected (0.04 sec)
- MySQL> show status like 'qcache%';
- +-------------------------+----------+
- | Variable_name | Value |
- +-------------------------+----------+
- | Qcache_free_blocks | 1 |
- | Qcache_free_memory | 16768408 |
- | Qcache_hits | 6 |
- | Qcache_inserts | 36 |
- | Qcache_lowmem_prunes | 0 |
- | Qcache_not_cached | 86 |
- | Qcache_queries_in_cache | 0 |
- | Qcache_total_blocks | 1 |
- +-------------------------+----------+
- 8 rows in set (0.06 sec)
看看当前缓存中有多少条信息:
- MySQL> show status like 'qcache_q%';
- +-------------------------+-------+
- | Variable_name | Value |
- +-------------------------+-------+
- | Qcache_queries_in_cache | 0 |
- +-------------------------+-------+
- 1 row in set (0.00 sec)
- MySQL> select sql_cache id, title, body from article;
- MySQL> show status like 'qcache_q%';
- +-------------------------+-------+
- | Variable_name | Value |
- +-------------------------+-------+
- | Qcache_queries_in_cache | 1 |
- +-------------------------+-------+
- 1 row in set (0.00 sec)
- MySQL> show status like 'qcache_f%';
- +--------------------+----------+
- | Variable_name | Value |
- +--------------------+----------+
- | Qcache_free_blocks | 1 |
- | Qcache_free_memory | 16766728 |
- +--------------------+----------+
- 2 rows in set (0.00 sec)
以上的相关内容就是对MySQL 查询缓存的介绍,望你能有所收获.
以上是“<b>MySQL 查询缓存的实际利用代码示例</b>[MySQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |
评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论