MySQL Variables table_open_cache 数据库 参数变量解释及正确配置使用
本站中文解释
table_open_cache变量是MySQL数据库中用于控制表打开缓存大小上限的参数。它可以帮助MySQL优化对特定数据表的读取和更新操作。
设置table_open_cache变量的方法是:
1.打开mysql命令行,以管理员账户登录。
2.输入以下命令帮助设置table_open_cache(默认值是2000):
SET GLOBAL table_open_cache = 4000;
3.重启MySQL数据库。
官方英文解释
table_open_cache
Command-Line Format | --table-open-cache=# |
---|---|
System Variable | table_open_cache |
Scope | Global |
Dynamic | Yes |
Type | Integer |
Default Value | 2000 |
Minimum Value | 1 |
Maximum Value | 524288 |
The number of open tables for all threads. Increasing this
value increases the number of file descriptors that
mysqld requires. The effective value of
this variable is the greater of the effective value of
open_files_limit
-
the effective value of
10 -
max_connections
/
, and 400; that is
2
MAX( (open_files_limit - 10 - max_connections) / 2, 400 )
You can check whether you need to increase the table cache by
checking the Opened_tables
status variable. If the value of
Opened_tables
is large and
you do not use FLUSH TABLES
often (which just forces all tables to be closed and
reopened), then you should increase the value of the
table_open_cache
variable.
For more information about the table cache, see
Section 8.4.3.1, “How MySQL Opens and Closes Tables”.