#### 什么是查詢緩存
mysql服務器提供的,用于緩存select語句結果的一種內部內存緩存系統。如果開啟了查詢緩存,將所有的查詢結果,都緩存起來,使用同樣的select語句,再次查詢時,直接返回緩存的結果即可.
#### 查看緩存設置
~~~
show variables like 'query_cache%';
~~~
~~~
+------------------------------+---------+
| Variable_name | Value |
+------------------------------+---------+
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 0 | //緩存空間大小
| query_cache_type | OFF | //是否有開啟緩存
| query_cache_wlock_invalidate | OFF |
+------------------------------+---------+
~~~
#### 開啟查詢緩存
在my.ini文件中:
1為開啟.

單位是字節,換算為128M.

修改完文件后重啟mysql服務.
#### 查看
~~~
+------------------------------+-----------+
| Variable_name | Value |
+------------------------------+-----------+
| query_cache_limit | 1048576 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 134217728 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
+------------------------------+-----------+
~~~
這樣就可以使用查詢緩存了.
#### 查看緩存空間使用情況
~~~
show status like 'Qcache%';
~~~
~~~
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| Qcache_free_blocks | 1 |
| Qcache_free_memory | 134197296 |
| Qcache_hits | 3 |
| Qcache_inserts | 2 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 5 |
| Qcache_queries_in_cache | 2 |
| Qcache_total_blocks | 7 |
+-------------------------+-----------+
~~~

- MySQL優化概述
- 存儲引擎的選擇
- innodb引擎
- myisam引擎
- memory引擎
- 查詢需優化語句
- 通用查詢日志
- 慢查詢日志
- profile機制
- 索引
- 索引基本介紹
- 索引類型
- 索引管理語法
- 創建索引主要事項
- 執行計劃
- 查看索引類型
- myisam索引數據結構
- innodb索引數據結構
- 索引覆蓋
- 索引使用原則
- 列獨立
- like查詢
- 復合索引使用
- or運算都具有索引
- mysql智能選擇
- 優化group by語句
- 前綴索引
- 全文索引
- 查詢緩存
- 查詢緩存操作
- 無緩存
- limit分頁優化
- 分區
- 分區介紹
- list分區
- range分區
- hash分區
- key(鍵值)分區
- 分區管理
- 分表
- 分表介紹
- 水平分表
- 垂直分表
- MySQL鎖機制
- 鎖機制介紹
- 鎖的幾種形式
- 表鎖操作
- 行鎖操作
- 數據碎片與維護
- 范式
- 第一范式
- 第二范式
- 第三范式
- 反三范式
- 主從復制
- 介紹
- 讀寫分離