Guest User

Untitled

a guest
Jul 18th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. mysql> explain SELECT SQL_NO_CACHE *
  2. -> FROM
  3. -> blog
  4. -> join
  5. -> (
  6. -> SELECT max(dateline) maxdateline
  7. -> , blog.userid userid
  8. -> FROM
  9. -> blog
  10. -> GROUP BY
  11. -> blog.userid
  12. -> ORDER BY
  13. -> max(dateline) DESC
  14. -> LIMIT
  15. -> 250
  16. -> ) grouper
  17. -> on ( blog.dateline = grouper.maxdateline and blog.userid = grouper.userid);
  18. +----+-------------+------------+-------+-----------------+----------+---------+------------------------------------+------+----------------------------------------------+
  19. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  20. +----+-------------+------------+-------+-----------------+----------+---------+------------------------------------+------+----------------------------------------------+
  21. | 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 250 | |
  22. | 1 | PRIMARY | blog | ref | dateline,userid | dateline | 8 | grouper.maxdateline,grouper.userid | 1 | |
  23. | 2 | DERIVED | blog | index | NULL | userid | 9 | NULL | 1054 | Using index; Using temporary; Using filesort |
  24. +----+-------------+------------+-------+-----------------+----------+---------+------------------------------------+------+----------------------------------------------+
  25. 3 rows in set (0.00 sec)
  26.  
  27. mysql> explain select t1.* from blog t1
  28. -> where t1.dateline= (
  29. -> SELECT max(t2.dateline) from blog t2 where t2.userid=t1.userid
  30. -> )
  31. -> order by t1.dateline desc
  32. -> limit 250;
  33. +----+--------------------+-------+-------+---------------+----------+---------+-------------------+-------+-------------+
  34. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  35. +----+--------------------+-------+-------+---------------+----------+---------+-------------------+-------+-------------+
  36. | 1 | PRIMARY | t1 | index | NULL | dateline | 9 | NULL | 15804 | Using where |
  37. | 2 | DEPENDENT SUBQUERY | t2 | ref | userid | userid | 4 | uantona.t1.userid | 15 | Using index |
  38. +----+--------------------+-------+-------+---------------+----------+---------+-------------------+-------+-------------+
  39. 2 rows in set (0.00 sec)
Add Comment
Please, Sign In to add comment