新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL 查詢緩存的實際應(yīng)用代碼
以下的文章主要向大家描述的是MySQL 查詢緩存的實際操作步驟以及對MySQL 查詢緩存的二十幾應(yīng)用代碼的描述,以下就是對查詢緩存的的大小查看以及監(jiān)視其相關(guān)性能這些相關(guān)內(nèi)容的描述。

目前成都創(chuàng)新互聯(lián)公司已為上1000+的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁空間、網(wǎng)站托管運營、企業(yè)網(wǎng)站設(shè)計、宿州網(wǎng)站維護等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
- 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)
查看***緩存結(jié)果,如果結(jié)果集大于該數(shù),不緩存。
- 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)
監(jiān)視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)
看看當(dāng)前緩存中有多少條信息:
- 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)
以上的相關(guān)內(nèi)容就是對MySQL 查詢緩存的介紹,望你能有所收獲。
【編輯推薦】
- 解決MySQL無法遠程訪問的3方案
- 甲骨文對MySQL數(shù)據(jù)庫做出十大承諾!
- 解決MySQL遠程訪問不允許得個好用方案
- MySQL 常用語句的基本用法的介紹
- 安裝MySQL-python的實際操作步驟
名稱欄目:MySQL 查詢緩存的實際應(yīng)用代碼
本文地址:http://m.fisionsoft.com.cn/article/cdhgjes.html


咨詢
建站咨詢
