新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL 查詢緩存的實際應(yīng)用代碼示例
以下的文章主要介紹的是MySQL 查詢緩存的實際應(yīng)用代碼以及查看MySQL 查詢緩存的大小 ,碎片整理,清除緩存以及監(jiān)視MySQL 查詢緩存性能的相關(guān)內(nèi)容的描述,以下就是具體內(nèi)容的描述,希望在你今后的學(xué)習(xí)中會有所幫助。

為沈陽等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及沈陽網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為網(wǎng)站設(shè)計、成都做網(wǎng)站、沈陽網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
- 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-python的實際操作步驟
- MySQL 常用語句的基本用法的介紹
- 解決MySQL無法遠程訪問的3方案
- PHP和MySQL存儲過程的實例演示
- MySQL delimiter 定義命令的結(jié)束標志
網(wǎng)站欄目:MySQL 查詢緩存的實際應(yīng)用代碼示例
轉(zhuǎn)載注明:http://fisionsoft.com.cn/article/cdiicdj.html


咨詢
建站咨詢
