AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 601974
Accepted
Ryan
Ryan
Asked: 2014-06-05 23:55:58 +0800 CST2014-06-05 23:55:58 +0800 CST 2014-06-05 23:55:58 +0800 CST

MySQL 查询缓存已启用但未使用

  • 772

我检查了查询缓存是否已启用

mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| have_query_cache | YES   |
+------------------+-------+
1 row in set (0.00 sec)

但似乎它没有被使用

mysql> SHOW STATUS LIKE 'Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        |
| Qcache_free_memory      | 16759648 |
| Qcache_hits             | 0        |
| Qcache_inserts          | 0        |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 21555882 |
| Qcache_queries_in_cache | 0        |
| Qcache_total_blocks     | 1        |
+-------------------------+----------+
8 rows in set (0.00 sec)

任何原因?

mysql
  • 4 4 个回答
  • 4870 Views

4 个回答

  • Voted
  1. Best Answer
    HBruijn
    2014-06-06T00:09:51+08:002014-06-06T00:09:51+08:00

    系统变量query_cache_type也需要设置为非零,因为缓存的存在并不意味着它可以使用。

    • 2
  2. Maxim Masiutin
    2017-05-02T17:23:41+08:002017-05-02T17:23:41+08:00

    另请注意,并非所有查询都是可缓存的。

    例如,如果一个查询包含像 NOW() 这样的函数,它就不会被缓存。哪些查询无法缓存的详细说明请查看:https ://dev.mysql.com/doc/refman/5.7/en/query-cache-operation.html

    • 1
  3. Mario Neubauer
    2015-03-27T05:22:42+08:002015-03-27T05:22:42+08:00

    您还应该检查在配置文件中写入设置的位置。

    我的问题是我将 qchace 设置放在文件末尾。尽管设置是通过执行反映的,mysql> SHOW STATUS LIKE 'Qcache%';但实际上没有缓存任何查询。

    将设置放在文件中的不同位置并重新启动它正在工作的mysql服务器后。

    在这里你可以看到我对 MySQL 5.6 的配置:

    [mysqld]
    bind-address=*
    #skip-networking
    #
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    innodb_buffer_pool_size = 128M
    #
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    # log_bin
    #
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    
    query_cache_type = 1
    query_cache_size =256M
    thread_concurrency=2
    sort_buffer_size=25M
    key_buffer=128M
    
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    # Recommended in standard MySQL setup
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    
    • 0
  4. Victor Sergienko
    2016-01-22T07:27:36+08:002016-01-22T07:27:36+08:00

    有一个MySQL 5.6 错误,在 5.6.9 中修复:“ if the db name (or table name) has a '-' (minus), it does not work”,仅在 InnoDB 上。

    • 0

相关问题

  • 开源与专有关系 db mgt 系统的优缺点是什么?

  • 在 solaris 10 上为 mysql 设置 max_allowed_pa​​cket

  • 如何移动 MySQL 的数据目录?

  • 通过 VPN 连接什么是远程服务器 IP?

  • mysql崩溃

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve