Mac 上的 Mysql 5.1:查询缓存不起作用

发布于 2024-08-24 07:50:03 字数 2081 浏览 4 评论 0原文

我想知道是否有人可以指出我正确的方向。我已经在我的 Snow Leopard OSX 机器上设置了本地 Mysql 5.1 沙箱,并且安装了 Macports Mysql 5.1,并且从各方面来看,都可以正常运行。它需要查询,数据库正在工作等等。唯一奇怪的是,查询缓存不起作用。我之前已经让它在 Linux 中运行,并在 5.0 xammp 安装中让它运行,但我很困惑为什么它在这个设置中不起作用。

一些细节...

% cat /etc/my.cnf | grep -i query_cache
query_cache_limit = 1M
query_cache_size = 32M
query_cache_type = 1

mysql> show variables like '%query_cache%';
+------------------------------+----------+
| Variable_name                | Value    |
+------------------------------+----------+
| have_query_cache             | YES      |
| query_cache_limit            | 1048576  |
| query_cache_min_res_unit     | 4096     |
| query_cache_size             | 33554432 |
| query_cache_type             | ON       |
| query_cache_wlock_invalidate | OFF      |
+------------------------------+----------+
6 rows in set (0.00 sec)

mysql> show status like '%Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        |
| Qcache_free_memory      | 33536856 |
| Qcache_hits             | 0        |
| Qcache_inserts          | 0        |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 433      |
| Qcache_queries_in_cache | 0        |
| Qcache_total_blocks     | 1        |
+-------------------------+----------+
8 rows in set (0.01 sec)

在我看来,一切都设置正确,这些基本上与我在 5.0 和 4.1 上使用的设置相同。大多数查询都是可缓存的,我并没有特别排除缓存。我不知道这是 Mac 问题、MacPorts 问题还是 5.1 问题,还是我个人的问题。谁能看出我的设置有什么问题吗?


好的,一些附加信息。这好像和Innodb有关。 MyISAM 查询似乎缓存得很好。

我的创新设置:

$ cat /etc/my.cnf | grep nno

# Uncomment the following if you are using InnoDB tables
innodb_file_per_table
innodb_data_home_dir = /opt/local/var/db/mysql5
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /opt/local/var/db/mysql5
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 12M
innodb_log_file_size = 50M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 300
innodb_flush_method=O_DIRECT

I was wondering if someone could point me in the right direction. I have set up a local Mysql 5.1 sandbox on my Snow Leopard OSX machine, I have the Macports Mysql 5.1 installed and, by all appearances, functioning. It takes queries, the database is working, etc. The only strange thing is, the query cache isn't functioning. I have gotten it functioning in linux before, and gotten it working in a 5.0 xammp install, but I am flummoxed as to why it isn't working in this set up.

Some details...

% cat /etc/my.cnf | grep -i query_cache
query_cache_limit = 1M
query_cache_size = 32M
query_cache_type = 1

mysql> show variables like '%query_cache%';
+------------------------------+----------+
| Variable_name                | Value    |
+------------------------------+----------+
| have_query_cache             | YES      |
| query_cache_limit            | 1048576  |
| query_cache_min_res_unit     | 4096     |
| query_cache_size             | 33554432 |
| query_cache_type             | ON       |
| query_cache_wlock_invalidate | OFF      |
+------------------------------+----------+
6 rows in set (0.00 sec)

mysql> show status like '%Qcache%';
+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_free_blocks      | 1        |
| Qcache_free_memory      | 33536856 |
| Qcache_hits             | 0        |
| Qcache_inserts          | 0        |
| Qcache_lowmem_prunes    | 0        |
| Qcache_not_cached       | 433      |
| Qcache_queries_in_cache | 0        |
| Qcache_total_blocks     | 1        |
+-------------------------+----------+
8 rows in set (0.01 sec)

It looks to me like everything is set up correctly, these are basically the same settings I have used on 5.0 and 4.1. The most of the queries are cache-able, and I am not excluding the cache specifically. I don't know if it a Mac issue, a MacPorts problem, or a 5.1 problem, or my personal problem. Can anyone see anything wrong with my setup?


Ok, some additional information. This seems to be related to Innodb. MyISAM queries seem to cache just fine.

My inno setup:

$ cat /etc/my.cnf | grep nno

# Uncomment the following if you are using InnoDB tables
innodb_file_per_table
innodb_data_home_dir = /opt/local/var/db/mysql5
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /opt/local/var/db/mysql5
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 12M
innodb_log_file_size = 50M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 300
innodb_flush_method=O_DIRECT

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森林散布 2024-08-31 07:50:03

您的数据库名称是否包含或其他非字母数字字符?

你使用innodb_file_per_table吗?

如果是这样,您需要通过转储和使用新名称恢复来重命名数据库。

Does you database name contain a dot or other non-alphanumeric characters?

Do you use innodb_file_per_table?

If so you'll need to rename your database by means of dumping and restoring with new name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文