TMP_TABLE_SIZE AND MAX_HEAP_TABLE_SIZE

https://www.saotn.org/mysql-innodb-performance-improvement/

The actual limit is determined from whichever of the values of tmp_table_size and max_heap_table_size is smaller. If an in-memory temporary table exceeds the limit, MySQL automatically converts it to an on-disk MyISAM table. 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 the values of the Created_tmp_disk_tables and Created_tmp_tables variables.


circumstances which could create temporary tables using MEMORY but that can go to MyISAM (so disk) if too large:
  • If there is an ORDER BY clause and a different GROUP BY clause, or if the ORDER BY or GROUP BY contains columns from tables other than the first table in the join queue;
  • DISTINCT combined with ORDER BY may require a temporary table;
  • In the case of the SQL_SMALL_RESULT option, MySQL uses an in-memory temporary table, unless the query also contains elements (described later) that require on-disk storage.
There are some conditions which will force the temporary table to use MyISAM :
  • Presence of a BLOB or TEXT column in the table;
  • Presence of any column in a GROUP BY or DISTINCT clause larger than 512 bytes;
  • Presence of any column larger than 512 bytes in the SELECT list, if UNION or UNION ALL;
tmp_table_size      = 16M
max_heap_table_size = 32M
max_connections = 1000

Value of tmp_table_size OR max_heap_table_size which ever is lower is taken
memory used if all connections are made 1000x16M=1600M  

No comments:

Post a Comment