2uzhan.com
Advertisement
Now Place:2uzhan.com » is tmpdir folder used for a select statement without where condition?

is tmpdir folder used for a select statement without where condition?

MySQL @ November 28, 2010   Views:0

is tmpdir folder used for a select statement without where condition like "select * from table_1;"?

Thanks.

--------------Solutions-------------

It depends.

No WHERE, no GROUP BY, no ORDER BY, no subqueries --> It should not need to create a tmp table, and hence won't need to use tmpdir.

Anything else --> It _might_ need to use tmp. It will prefer to use a MEMORY temp table, but there are several situations where that is not possible, or the temp gets too big and is converted to a MyISAM table, thereby using tmp.

Do
EXPLAIN SELECT ...
The last column might say "Using temporary" and/or "Using filesort". Those indicate that it _might_ be using tmp. (Or it might not.) If it says neither of them, it will not (I think) use tmp. Example:

mysql> explain select * from ts group by 1;
+----+-------------+-------+------+---------------+------+---------+------+------+---------------------------------+
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                           |
+----+-------------+-------+------+---------------+------+---------+------+------+---------------------------------+
|  1 | SIMPLE      | ts    | ALL  | NULL          | NULL | NULL    | NULL |   20 | Using temporary; Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+------+---------------------------------+
Tags:
© 2018 2uzhan.com Contact