日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MySQL 查詢緩存的實際應用代碼

以下的文章主要向大家描述的是MySQL 查詢緩存的實際操作步驟以及對MySQL 查詢緩存的二十幾應用代碼的描述,以下就是對查詢緩存的的大小查看以及監(jiān)視其相關性能這些相關內(nèi)容的描述。

目前成都創(chuàng)新互聯(lián)公司已為上1000+的企業(yè)提供了網(wǎng)站建設、域名、網(wǎng)頁空間、網(wǎng)站托管運營、企業(yè)網(wǎng)站設計、宿州網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

 
 
 
  1. MySQL> select @@query_cache_type;  
  2. +--------------------+  
  3. | @@query_cache_type |  
  4. +--------------------+  
  5. | ON |   
  6. +--------------------+  
  7. MySQL> set query_cache_type=off;  
  8. MySQL> set query_cache_type=on;  
  9. MySQL>   
  10. MySQL> select sql_cache id, title, body from article;  
  11. MySQL> select sql_no_cache id, title, body from article;  
  12. MySQL> show variables like 'have_query_cache';  
  13. +------------------+-------+  
  14. | Variable_name | Value |  
  15. +------------------+-------+  
  16. | have_query_cache | YES |   
  17. +------------------+-------+  
  18. 1 row in set (0.00 sec)  

查看MySQL 查詢緩存的大小

 
 
 
  1. MySQL> select @@global.query_cache_size;  
  2. +---------------------------+  
  3. | @@global.query_cache_size |  
  4. +---------------------------+  
  5. | 16777216 |   
  6. +---------------------------+  
  7. 1 row in set (0.00 sec)  
  8. MySQL> select @@query_cache_size;  
  9. +--------------------+  
  10. | @@query_cache_size |  
  11. +--------------------+  
  12. | 16777216 |   
  13. +--------------------+  
  14. 1 row in set (0.00 sec)   

查看***緩存結果,如果結果集大于該數(shù),不緩存。

 
 
 
  1. MySQL> select @@global.query_cache_limit;  
  2. +----------------------------+  
  3. | @@global.query_cache_limit |  
  4. +----------------------------+  
  5. | 1048576 |   
  6. +----------------------------+  
  7. 1 row in set (0.00 sec) 

碎片整理

 
 
 
  1. MySQL> flush query cache  
  2. -> ;  
  3. Query OK, 0 rows affected (0.00 sec)  

清除緩存

 
 
 
  1. MySQL> reset query cache  
  2. -> ;  
  3. Query OK, 0 rows affected (0.00 sec) 

監(jiān)視MySQL 查詢緩存性能:

 
 
 
  1. MySQL> flush tables;  
  2. Query OK, 0 rows affected (0.04 sec)  
  3. MySQL> show status like 'qcache%';  
  4. +-------------------------+----------+  
  5. | Variable_name | Value |  
  6. +-------------------------+----------+  
  7. | Qcache_free_blocks | 1 |   
  8. | Qcache_free_memory | 16768408 |   
  9. | Qcache_hits | 6 |   
  10. | Qcache_inserts | 36 |   
  11. | Qcache_lowmem_prunes | 0 |   
  12. | Qcache_not_cached | 86 |   
  13. | Qcache_queries_in_cache | 0 |   
  14. | Qcache_total_blocks | 1 |   
  15. +-------------------------+----------+  
  16. 8 rows in set (0.06 sec) 

看看當前緩存中有多少條信息:

 
 
 
  1. MySQL> show status like 'qcache_q%';  
  2. +-------------------------+-------+  
  3. | Variable_name | Value |  
  4. +-------------------------+-------+  
  5. | Qcache_queries_in_cache | 0 |   
  6. +-------------------------+-------+  
  7. 1 row in set (0.00 sec)  
  8. MySQL> select sql_cache id, title, body from article;  
  9. MySQL> show status like 'qcache_q%';  
  10. +-------------------------+-------+  
  11. | Variable_name | Value |  
  12. +-------------------------+-------+  
  13. | Qcache_queries_in_cache | 1 |   
  14. +-------------------------+-------+  
  15. 1 row in set (0.00 sec)  
  16. MySQL> show status like 'qcache_f%';  
  17. +--------------------+----------+  
  18. | Variable_name | Value |  
  19. +--------------------+----------+  
  20. | Qcache_free_blocks | 1 |   
  21. | Qcache_free_memory | 16766728 |   
  22. +--------------------+----------+  
  23. 2 rows in set (0.00 sec)  

以上的相關內(nèi)容就是對MySQL 查詢緩存的介紹,望你能有所收獲。

【編輯推薦】

  1. 解決MySQL無法遠程訪問的3方案
  2. 甲骨文對MySQL數(shù)據(jù)庫做出十大承諾!
  3. 解決MySQL遠程訪問不允許得個好用方案
  4. MySQL 常用語句的基本用法的介紹
  5. 安裝MySQL-python的實際操作步驟

網(wǎng)站題目:MySQL 查詢緩存的實際應用代碼
網(wǎng)頁網(wǎng)址:http://www.5511xx.com/article/cdhgjes.html