MySQL的table_cache/table_open_cache参数
2014-04-21 17:03
330 查看
MySQL的table_cache/table_open_cache参数
调整这个参数要参考open_tables及opened_tablesOpen_tables:当前打开表的缓存数
Opened_tables:曾经打开表的缓存数,会一直累加。
mysql> show variables like ‘table_cache%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| table_cache | 64 |
+—————+——-+
1 row in set (0.01 sec)
mysql> show global status like ‘open%table%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| Open_tables | 30 |
| Opened_tables | 136 |
+—————+——-+
2 rows in set (0.00 sec)
执行flush tables后,open_tables会清0,opened_tables则不会。因为flush_tables后,mysql会关闭打开的缓存表。
mysql> flush tables;
Query OK, 0 rows affected (0.01 sec)
mysql> show global status like ‘open%table%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| Open_tables | 0 |
| Opened_tables | 136 |
+—————+——-+
2 rows in set (0.00 sec)
这里查询张表t1
mysql> select count(*) from t1;
+———-+
| count(*) |
+———-+
| 0 |
+———-+
1 row in set (0.00 sec)
mysql> show global status like ‘open%table%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| Open_tables | 1 | —增加了1
| Opened_tables | 137 | —增加了1
+—————+——-+
2 rows in set (0.00 sec)
再执行一次
mysql> select count(*) from t1;
+———-+
| count(*) |
+———-+
| 0 |
+———-+
1 row in set (0.00 sec)
mysql> show global status like ‘open%table%’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| Open_tables | 1 | —没有加1
| Opened_tables | 137 | —没有加1
+—————+——-+
2 rows in set (0.00 sec)
因为t1已经打开过一次了。
BTW:如果opened_tables每秒中打开的比较多,一般情况下,说明table_cahce太小了,但也存在另外一种情况:table cahce没有全部使用,临时表的打开,也会导致opened_tables的增加。
相关文章推荐
- mysql优化之连接优化(open-files-limit与table_open_cache)
- windows mysql下max_open_files: 2048 max_connections: * table_cache: *
- table_open_cache参数对mysql性能的影响
- MYSQL实践心得:table_open_cache的设置
- MYSQL实践心得:table_open_cache的设置
- table_open_cache参数对mysql性能的影响
- MySQL启动参数(三) —— table_open_cache
- mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64的解决
- Mysql—— [Warning] Changed limits: max_open_files: 2048 max_connections:800 table_cache: 619
- mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64解决办法
- MySQL 5.6下table_open_cache参数合理配置详解
- mysql 性能参数 table_open_cache
- Mysql 之table_open_cache
- mysql提示Changed limits: max_open_files: 2048 max_connections: 1910 table_cache: 64的解决
- MySQL 5.6下table_open_cache参数优化合理配置详解
- Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist的解决方法
- Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
- MySQL优化经验 key_buffer_size,query_cache_size,table_cache
- mysql报错Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
- mysql启动报错:Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist