table_open_cache Open_tables Opened_tables

来源:互联网 发布:beta系数 知乎 编辑:程序博客网 时间:2024/06/06 02:37

table_open_cache

指定表高速缓存的大小。

每当MySQL访问一个表时,如果在表缓冲区中还有空间,该表就被打开并放入其中,这样可以更快地访问表内容。

通过检查峰值时间的状态值Open_tables和Opened_tables,可以决定是否需要增加table_open_cache的值。

如果你发现open_tables等于table_open_cache,并且opened_tables在不断增长,那么你就需要增加table_open_cache的值了(上述状态值可以使用SHOW GLOBAL STATUS LIKE ‘Open%tables’获得)。

注意,不能盲目地把table_open_cache设置成很大的值。如果设置得太高,可能会造成文件描述符不足,从而造成性能不稳定或者连接失败。


mysql> show variables like '%table_open_cache%';

+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| table_open_cache           | 8192  |
| table_open_cache_instances | 1     |
+----------------------------+-------+
2 rows in set (0.00 sec)


mysql> show global status like '%open%';
+----------------------------+------------+
| Variable_name              | Value      |
+----------------------------+------------+
| Com_ha_open                | 0          |
| Com_show_open_tables       | 0          |
| Innodb_num_open_files      | 1024       |
| Open_files                 | 112        |
| Open_streams               | 0          |
| Open_table_definitions     | 4330       |
| Open_tables                | 4557       |
| Opened_files               | 156740806  |
| Opened_table_definitions   | 21563119   |
| Opened_tables              | 172504016  |
| Slave_open_temp_tables     | 0          |
| Table_open_cache_hits      | 1609800574 |
| Table_open_cache_misses    | 18769556   |
| Table_open_cache_overflows | 18733120   |
+----------------------------+------------+

14 rows in set (0.00 sec)


mysql> show global status like '%open%';
+----------------------------+------------+
| Variable_name              | Value      |
+----------------------------+------------+
| Com_ha_open                | 0          |
| Com_show_open_tables       | 0          |
| Innodb_num_open_files      | 1024       |
| Open_files                 | 112        |
| Open_streams               | 0          |
| Open_table_definitions     | 4395       |
| Open_tables                | 4685       |
| Opened_files               | 156741147  |
| Opened_table_definitions   | 21563184   |
| Opened_tables              | 172509760  |
| Slave_open_temp_tables     | 0          |
| Table_open_cache_hits      | 1609879796 |
| Table_open_cache_misses    | 18769684   |
| Table_open_cache_overflows | 18733120   |
+----------------------------+------------+
14 rows in set (0.00 sec)


如果show processlist显示很多opening table closing table很多,那么就应该调整这些参数了

0 0
原创粉丝点击