自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL 查詢緩存的實際應(yīng)用代碼

數(shù)據(jù)庫 MySQL
此文章主要是想大家介紹的是MySQL 查詢緩存的實際操作流程以及其實際操作中所要用到的代碼的示例,以下就是文章的詳細內(nèi)容描述。

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

  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)   

 

查看***緩存結(jié)果,如果結(jié)果集大于該數(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) 

 

看看當(dāng)前緩存中有多少條信息:

 

  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)  

 

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

【編輯推薦】

  1. 解決MySQL無法遠程訪問的3方案
  2. 甲骨文對MySQL數(shù)據(jù)庫做出十大承諾!
  3. 解決MySQL遠程訪問不允許得個好用方案
  4. MySQL 常用語句的基本用法的介紹
  5. 安裝MySQL-python的實際操作步驟
責(zé)任編輯:佚名 來源: cnblogs
相關(guān)推薦

2010-06-02 17:46:54

MySQL 查詢緩存

2010-05-19 12:44:58

2010-05-18 16:29:44

MySQL修改表

2010-05-17 09:25:34

MySql 編碼設(shè)置

2010-05-31 14:59:36

PHP + MySQL

2010-05-18 17:24:44

MySQL修改表字段

2010-05-12 09:42:24

MySQL 列值比較

2010-05-25 18:21:28

MySQL連接數(shù)據(jù)庫

2010-05-04 15:15:39

Oracle分頁查詢

2024-01-23 09:57:50

MySQL數(shù)據(jù)庫

2010-04-21 13:31:11

Oracle時間

2010-04-09 16:26:53

Oracle join

2010-06-03 08:59:50

MySQL Query

2010-06-07 10:08:52

MySQL FLUSH

2010-05-24 09:57:08

2010-06-02 17:31:10

MySQL定時任務(wù)

2010-04-12 12:30:44

Oracle 安裝腳本

2010-04-27 09:28:55

綁定變量

2010-05-18 13:34:42

MySQL條件sele

2010-05-21 16:41:22

MySQL SHOW
點贊
收藏

51CTO技術(shù)棧公眾號