Using index, using temporary, using filesort - how to fix this?

后端 未结 3 2052
春和景丽
春和景丽 2020-11-29 00:57

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

3条回答
  •  悲&欢浪女
    2020-11-29 01:09

    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

提交回复
热议问题