All pastes #271303 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-08 03:57 UTC
rendered paste body
mysql> EXPLAIN SELECT root.messageid, ( SELECT MAX(reply.senttime) FROM zeroseventwo_forummessages reply WHERE reply.touid = root.messageid OR reply.messageid = root.messageid) as replytime, root.thread FROM zeroseventwo_forummessages root WHERE root.thread = 1 ORDER BY replytime DESC;
+----+--------------------+-------+------+---------------+--------+---------+-------+------+-----------------------------+
| id | select_type        | table | type | possible_keys | key    | key_len | ref   | rows | Extra                       |
+----+--------------------+-------+------+---------------+--------+---------+-------+------+-----------------------------+
|  1 | PRIMARY            | root  | ref  | thread        | thread | 2       | const |   80 | Using where; Using filesort |
|  2 | DEPENDENT SUBQUERY | reply | ALL  | PRIMARY,touid | NULL   | NULL    | NULL  |  318 | Using where                 |
+----+--------------------+-------+------+---------------+--------+---------+-------+------+-----------------------------+
2 rows in set (0.00 sec)

mysql> EXPLAIN SELECT root.messageid, ( SELECT MAX(reply.senttime) FROM zeroseventwo_forummessages reply WHERE reply.touid = root.messageid ) as replytime, root.thread FROM zeroseventwo_forummessages root WHERE root.thread = 1 ORDER BY replytime DESC; +----+--------------------+-------+------+---------------+--------+---------+-----------------------+------+-----------------------------+
| id | select_type        | table | type | possible_keys | key    | key_len | ref                   | rows | Extra                       |
+----+--------------------+-------+------+---------------+--------+---------+-----------------------+------+-----------------------------+
|  1 | PRIMARY            | root  | ref  | thread        | thread | 2       | const                 |   80 | Using where; Using filesort |
|  2 | DEPENDENT SUBQUERY | reply | ref  | touid         | touid  | 5       | phpdip.root.messageid |    4 | Using where                 |
+----+--------------------+-------+------+---------------+--------+---------+-----------------------+------+-----------------------------+
2 rows in set (0.01 sec)