I\'m working on a event tracking system which uses a handful of lookup tables as well as the primary logging table. In a report I\'m writing, an object can be selected to
These are the following conditions under which temporary tables are created. UNION queries use temporary tables.
Some views require temporary tables, such those evaluated using the TEMPTABLE algorithm, or that use UNION or aggregation.
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, a temporary table is created.
DISTINCT combined with ORDER BY may require a temporary table.
If you use 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.
Follow this link by mysql: http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html