日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 禁用查询缓存 query cache

發布時間:2024/8/26 数据库 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 禁用查询缓存 query cache 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

os:centos 6.8
mysql: 5.5.49

MySQL Query Cache 會緩存select 查詢,但是在調優sql查詢及測試數據庫的性能時需要禁用該功能。

查看變量、狀態

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)

注意參數 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

轉載于:https://www.cnblogs.com/ctypyb2002/p/9792955.html

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的mysql 禁用查询缓存 query cache的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。