MySQL uses internal temporary tables to execute some queries. Usually the tables are stored in memory and on disk if some conditions are met :
Some conditions prevent the use of an in-memory temporary table, in which case the server uses an on-disk table instead:
-
Presence of any string column in a
GROUP BYorDISTINCTclause larger than 512 bytes -
Presence of any string column with a maximum length larger than 512 (bytes for binary strings, characters for nonbinary strings) in the …