這功能一定要 MySQL 4 以上才有支援...

我發現很多人不知道也不會開啟該設定..
就算預設是Open得.但是預設上沒有配置QueryCacheMemory 所以等於沒開一樣...

各位可以看一下 show status; 後得資料...
其中.
代碼:


Qcache_queries_in_cache 0
Qcache_inserts 0
Qcache_hits 0
Qcache_lowmem_prunes 0
Qcache_not_cached 0
Qcache_free_memory 0
Qcache_free_blocks 0
Qcache_total_blocks 0


應該是各位沒有開啟得時候現在得狀態...

在 /etc/my.cnf 中得 [mysqld]區段加入下面這樣得設定..
代碼:

query_cache_size = 2M


實際配置記憶體量請自己衡量...
可參考 /usr/share/mysql/my-large.cnf 中得建議設定.

然後重新啟動mysql...
看看 show status;
代碼:


Qcache free blocks 1
Qcache free memory 616568
Qcache hits 289
Qcache inserts 146
Qcache lowmem prunes 0
Qcache not cached 74
Qcache queries in cache 146
Qcache total blocks 315



你就會看到 cache 已經打開,且配置完成記憶體,然後 hits 則是目前從cache回傳資料次數, queries in cache 則表示有多少資料目前在 cache中. 
arrow
arrow
    全站熱搜

    kevin0523 發表在 痞客邦 留言(0) 人氣()