zuntan02のはてなブログ

備忘録的なものです。時々職場の技術者ブログにも転記してますが、メインはこちらで。

MySQL5.6.8以前と以後とでquery_cache_typeのデフォルト値が違うので注意

5.6.8以前はquery_cache_size=0のものを適当に大きな値にしてやればOK、だったのが、
以降は明示的にquery_cache_type=1にしてやる必要がある。

> (MySQL 5.6.8 より前では、1 のデフォルトの query_cache_type で、デフォルトのサイズは 0 です。)
MySQL :: MySQL 5.6 リファレンスマニュアル :: 8.9.3.3 クエリーキャッシュの構成


なんか古い手順のままやってたらどうしてもキャッシュされてなくてあれ?みたいなことが。。。

↓こんな感じだった

mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| have_query_cache | YES   |
+------------------+-------+

mysql> show variables like 'query_cache_%';
+------------------------------+-----------+
| Variable_name                | Value     |
+------------------------------+-----------+
| query_cache_limit            | 1048576   |
| query_cache_min_res_unit     | 4096      |
| query_cache_size             | 524288000 |
| query_cache_type             | OFF       |★これ★
| query_cache_wlock_invalidate | OFF       |
+------------------------------+-----------+

mysql> SHOW STATUS LIKE 'Qcache%';
+-------------------------+------------+
| Variable_name           | Value      |
+-------------------------+------------+
| Qcache_free_blocks      | 1          |
| Qcache_free_memory      | 524269912  |
| Qcache_hits             | 0          |
| Qcache_inserts          | 0          |
| Qcache_lowmem_prunes    | 0          |
| Qcache_not_cached       | 1339960605 |
| Qcache_queries_in_cache | 0          |
| Qcache_total_blocks     | 1          |
+-------------------------+------------+

メモまで。