zoukankan      html  css  js  c++  java
  • Using index, using temporary, using filesort

    解释一:

    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

    译文:
    以下是创建临时表的条件。 UNION查询使用临时表。

    某些视图需要使用TEMPTABLE算法评估的临时表,或使用UNION或聚合的临时表。

    如果存在ORDER BY子句和不同的GROUP BY子句,或者如果ORDER BY或GROUP BY包含来自联接队列中第一个表以外的表的列,则会创建一个临时表。

    与ORDER BY组合的DISTINCT可能需要临时表。

    如果使用SQL_SMALL_RESULT选项,MySQL将使用内存中的临时表,除非该查询还包含需要磁盘存储的元素(稍后介绍)。

    按照mysql的这个链接:http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html

    解释二:

    Updated for MySQL 5.7 (src):

    The server creates temporary tables under conditions such as these:

    Evaluation of UNION statements, with some exceptions described later.

    Evaluation of some views, such those that use the TEMPTABLE algorithm, UNION, or aggregation.

    Evaluation of derived tables (subqueries in the FROM clause).

    Tables created for subquery or semi-join materialization (see Section 8.2.2, “Optimizing Subqueries, Derived Tables, and View References”).

    Evaluation of statements that contain an ORDER BY clause and a different GROUP BY clause, or for which the ORDER BY or GROUP BY contains columns from tables other than the first table in the join queue.

    Evaluation of DISTINCT combined with ORDER BY may require a temporary table.

    For queries that use the SQL_SMALL_RESULT modifier, MySQL uses an in-memory temporary table, unless the query also contains elements (described later) that require on-disk storage.

    To evaluate INSERT ... SELECT statements that select from and insert into the same table, MySQL creates an internal temporary table to hold the rows from the SELECT, then inserts those rows into the target table. See Section 13.2.5.1, “INSERT ... SELECT Syntax”.

    Evaluation of multiple-table UPDATE statements.

    Evaluation of GROUP_CONCAT() or COUNT(DISTINCT) expressions.

    译文:

    更新MySQL 5.7(src):

    服务器在如下条件下创建临时表:

    UNION报表的评估,稍后会有一些例外情况。

    评估一些视图,例如使用TEMPTABLE算法,UNION或聚合的视图。

    派生表的评估(FROM子句中的子查询)。

    为子查询或半连接实现创建的表(请参见第8.2.2节“优化子查询,派生表和视图引用”)。

    评估包含ORDER BY子句和不同GROUP BY子句的语句,或者ORDER BY或GROUP BY包含来自联接队列中第一个表以外的表的列的语句。

    DISTINCT与ORDER BY结合使用可能需要一个临时表。

    对于使用SQL_SMALL_RESULT修饰符的查询,MySQL使用内存中的临时表,除非查询还包含需要磁盘存储的元素(稍后介绍)。

    为了评估从同一个表中选择并插入到同一个表中的INSERT ... SELECT语句,MySQL创建一个内部临时表来存放SELECT中的行,然后将这些行插入到目标表中。请参见第13.2.5.1节“INSERT ... SELECT语法”。

    评估多表UPDATE语句。

    评估GROUP_CONCAT()或COUNT(DISTINCT)表达式。
    原文地址:https://stackoverflow.com/questions/13633406/using-index-using-temporary-using-filesort-how-to-fix-this

  • 相关阅读:
    vue 进行ajax请求,使用axios
    webpack 小记
    js闭包
    git小记
    sublime text3 插件安装
    mysql安装
    四十九、django单表操作,多表操作,一对多,多对多,分组查询,聚合查询,F、Q查询,自定义char字段,事务,only与defer ,choices字段
    四十八、模板层,标签,过滤器,继承和导入
    四十七、django路由匹配,分组,反向解析,路由分发,视图层
    四十六、django配置及增删改查
  • 原文地址:https://www.cnblogs.com/jpfss/p/9156859.html
Copyright © 2011-2022 走看看