MySQL Variables tmp_table_size 数据库 参数变量解释及正确配置使用
本站中文解释
参数
tmp_table_size参数用于控制MySQL系统可以使用的临时表的内存大小。受该参数指定的内存大小决定,以内存中计算临时表,最大可以为16MB。如果临时表内存大小超过设定值,那么MySQL系统会将临时表写入磁盘,消耗更多的I/O资源,严重的,影响MySQL的正常工作。所以,在使用临时表操作,需要合理设定参数tmp_table_size,确保临时表在系统内部正常运行。
tmp_table_size参数可以通过在MySQL配置文件my.cnf文件中添加如下语句进行修改:
tmp_table_size = 16M
上面的代码将临时表的内存大小设定为16MB,可以根据临时表大小的不同,调整参数的值。
官方英文解释
tmp_table_size
Command-Line Format | --tmp-table-size=# |
---|---|
System Variable | tmp_table_size |
Scope | Global, Session |
Dynamic | Yes |
Type | Integer |
Default Value | 16777216 |
Minimum Value | 1024 |
Maximum Value | 18446744073709551615 |
Unit | bytes |
The maximum size of internal in-memory temporary tables. This
variable does not apply to user-created
MEMORY
tables.
The actual limit is the smaller of
tmp_table_size
and
max_heap_table_size
. When an
in-memory temporary table exceeds the limit, MySQL
automatically converts it to an on-disk temporary table. The
internal_tmp_disk_storage_engine
option defines the storage engine used for on-disk temporary
tables.
Increase the value of
tmp_table_size
(and
max_heap_table_size
if
necessary) if you do many advanced GROUP BY
queries and you have lots of memory.
You can compare the number of internal on-disk temporary
tables created to the total number of internal temporary
tables created by comparing
Created_tmp_disk_tables
and
Created_tmp_tables
values.
See also Section 8.4.4, “Internal Temporary Table Use in MySQL”.