Mysql tmp_table_size and max_heap_table_size, mysqltmptablesize

Source: Internet
Author: User

Mysql tmp_table_size and max_heap_table_size, mysqltmptablesize

16 GB memory configuration

Copy codeThe Code is as follows:
Tmp_table_size = 64 M

Let's talk about tmp_table_size first:

It specifies the maximum value of the temporary internal memory table, and each thread must be allocated. (The actual limitation is the minimum values of tmp_table_size and max_heap_table_size .) If the temporary memory table exceeds the limit, MySQL automatically converts it to a disk-based MyISAM table and stores it in the specified tmpdir directory. The default value is:

Mysql> show variables like "tmpdir ";
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Tmpdir |/tmp/|
+ --------------- + ------- +

When optimizing query statements, avoid using temporary tables. If you cannot, ensure that these temporary tables exist in the memory. If necessary, you have a lot of group by statements and a lot of memory to increase the value of tmp_table_size (and max_heap_table_size. This variable is not applicable to memory tables created by users ).

You can compare the total number of temporary tables based on disks and the total number of temporary tables created in the memory (Created_tmp_disk_tables and Created_tmp_tables). The general proportional relationship is as follows:

Created_tmp_disk_tables/Created_tmp_tables <5%

Max_heap_table_size

This variable defines the size of the memory table that can be created by the user. This value is used to calculate the maximum row value of the memory table. This variable supports dynamic changes, that is, set @ max_heap_table_size = #

But there is no use for an existing memory table, unless the table is re-created (create table), modified (alter table), or truncate table. When the service is restarted, the existing memory table is set to the global max_heap_table_size value.

This variable and tmp_table_size limit the size of the internal memory table.

For more details, see "How does MySQL use an internal temporary table ?" And "memory storage engine"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.