mysql> show variables like "table%";
+-------------------------+--------+
| Variable_name | Value |
+-------------------------+--------+
| table_definition_cache | 256 |
| table_lock_wait_timeout | 50 |
| table_open_cache | 1024 |
| table_type | InnoDB |
+-------------------------+--------+
4 rows in set (0.00 sec)
table_open_cache :mysql每打开一个表,都会读入一些数据到table_open_cache 缓存 中
当mysql在这个缓存中找不到相应的信息时,才会去磁盘上直接读取。
mysql> show status like "open%";
+--------------------------+----------+
| Variable_name | Value |
+--------------------------+----------+
| Open_files | 66 |
| Open_streams | 0 |
| Open_table_definitions | 135 |
| Open_tables | 302 |
| Opened_files | 86399846 |
| Opened_table_definitions | 0 |
| Opened_tables | 0 |
+--------------------------+----------+
7 rows in set (0.00 sec)
Open_tables 当前打开的表数目 302 。table_open_cache 1024 。所有现在没必要对缓存进行调整。
mysql> show variables like "thread%";
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 81208905
Current database: ZXX
+-------------------+---------------------------+
| Variable_name | Value |
+-------------------+---------------------------+
| thread_cache_size | 64 |
| thread_handling | one-thread-per-connection |
| thread_stack | 196608 |
+-------------------+---------------------------+
3 rows in set (0.04 sec)
每当客户端连接到mysql数据库,mysql数据库就会创建以个线程为它服务
但是首先mysql回去thread_cache中寻找可用的线程,找不到才会创建新的线程
当前线程状况:
mysql> show status like "thread%";
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| Threads_cached | 61 |
| Threads_connected | 3 |
| Threads_created | 2371 |
| Threads_running | 3 |
+-------------------+-------+
联系客服