mysql 禁用查询缓存 query cache
生活随笔
收集整理的這篇文章主要介紹了
mysql 禁用查询缓存 query cache
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
os:centos 6.8
mysql: 5.5.49
MySQL Query Cache 會緩存select 查詢,但是在調(diào)優(yōu)sql查詢及測試數(shù)據(jù)庫的性能時需要禁用該功能。
查看變量、狀態(tài)
mysql> show global variables like '%cache%'; +------------------------------+----------------------+ | Variable_name | Value | +------------------------------+----------------------+ | binlog_cache_size | 8388608 | | binlog_stmt_cache_size | 32768 | | have_query_cache | YES | | key_cache_age_threshold | 300 | | key_cache_block_size | 1024 | | key_cache_division_limit | 100 | | max_binlog_cache_size | 536870912 | | max_binlog_stmt_cache_size | 18446744073709547520 | | metadata_locks_cache_size | 1024 | | query_cache_limit | 4194304 | | query_cache_min_res_unit | 4096 | | query_cache_size | 134217728 | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | | stored_program_cache | 256 | | table_definition_cache | 400 | | table_open_cache | 400 | | thread_cache_size | 16 | +------------------------------+----------------------+ 18 rows in set (0.00 sec)mysql> show global status like '%cache%hit%'; +-------------------------+--------+ | Variable_name | Value | +-------------------------+--------+ | Qcache_hits | 552743 | | Ssl_callback_cache_hits | 0 | | Ssl_session_cache_hits | 0 | +-------------------------+--------+ 3 rows in set (0.00 sec)注意參數(shù) query_cache_size、query_cache_type
臨時會話修改
mysql> set query_cache_type=0;臨時全局修改
mysql> set global query_cache_size=0; mysql> set global query_cache_type=0;永久修改
# vi my.cnf query_cache_type=0 query_cache_size=0還有一種方式是添加類似oracle的hint
select sql_no_cache count(*) from mysql.user;mysql 5.5 文檔上描述
Note
Query cache was deprecated in MySQL 5.7 and removed in MySQL 8.0 (and later).
參考:
https://dev.mysql.com/doc/refman/5.5/en/mysql-installer-workflow.html
轉(zhuǎn)載于:https://www.cnblogs.com/ctypyb2002/p/9792955.html
與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的mysql 禁用查询缓存 query cache的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jenkins使用docker部署web
- 下一篇: 采用vue-cli安装的一些注意点