日期:2014-05-16  浏览次数:20677 次

table_cache变量
整理服务器配置文件参数
发现table_cache参数在mysql手册和网络上mysql优化中的解释不一致 
在此向大家求证一下
mysql手册5.1.51中解释为:
table_cache global numeric
所有线程打开的表的数目。增大该值可以增加mysqld需要的文件描述符的数量。你可以检查Opened_tables状态变量来检查你是否需要增加表缓存。如果Opened_tables值较大,并且多次执行FLUSH TABLES(只是强制关闭所有表并重新),则应增加table_cache变量的值。
在网上看到博文中的总结是:
table_cache指定表高速缓存的大小。每当MySQL访问一个表时,如果在表缓冲区中还有空间,该表就被打开并放入其中,这样可以更快地访问表内容。通过检查峰值时间的状态值Open_tables和Opened_tables,可以决定是否需要增加table_cache的值。如果你发现open_tables等于table_cache,并且opened_tables在不断增长,那么你就需要增加table_cache的值了(上述状态值可以使用SHOW STATUS LIKE ‘Open%tables’获得)。注意,不能盲目地把table_cache设置成很大的值。如果设置得太高,可能会造成文件描述符不足,从而造成性能不稳定或者连接失败。
但是mysql中没有这个变量:
mysql> show variables like 'table_cache';
Empty set (0.00 sec)
一个是线程打开表的数量 一个是高速缓存的大小 高速缓存的大小=线程打开表的数目?


------解决方案--------------------
MySQL is multi-threaded, so there may be many clients issuing queries for a given table simultaneously. To minimize the problem with multiple client threads having different states on the same table, the table is opened independently by each concurrent thread. 

The table cache is used to cache file descriptors for open tables and there is a single cache shared by all clients. Increasing the size of the table cache allows mysqld to keep more tables open simultanously by reducing the number of file open and close operations that must be done. If the value of Open_tables is approaching the value of table_cache, this may indicate performance problems. 




以手册为准吧。
------解决方案--------------------
http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_table_cache
This is the old name of table_open_cache before MySQL 5.1.3. From 5.1.3 on, use table_open_cache instead.
5.1.3开始,使用的是table_open_cache了。

root@localhost : (none) 04:54:30> show global variables like 'table_open_cache ';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| table_open_cache | 1024 |
+------------------+-------+
1 row in set (0.00 sec)