Guest User

Untitled

a guest
May 26th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. mysql> select topic_id from article_threads where topic_id > 0 and topic_id not in (select id from kids);
  2. Empty set (8.66 sec)
  3.  
  4. mysql> explain select topic_id from article_threads where topic_id not in (select id from kids);
  5. +----+--------------------+-----------------+-------+---------------+------+---------+------+------+--------------------------+
  6. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
  7. +----+--------------------+-----------------+-------+---------------+------+---------+------+------+--------------------------+
  8. | 1 | PRIMARY | article_threads | index | NULL | tid | 5 | NULL | 4015 | Using where; Using index |
  9. | 2 | DEPENDENT SUBQUERY | kids | ALL | NULL | NULL | NULL | NULL | 2033 | Using where |
  10. +----+--------------------+-----------------+-------+---------------+------+---------+------+------+--------------------------+
  11. 2 rows in set (0.00 sec)
  12.  
  13. mysql> select count(*) from article_threads;
  14. +----------+
  15. | count(*) |
  16. +----------+
  17. | 4015 |
  18. +----------+
  19. 1 row in set (0.00 sec)
  20.  
  21. mysql> select count(*) from kids;
  22. +----------+
  23. | count(*) |
  24. +----------+
  25. | 2033 |
  26. +----------+
  27. 1 row in set (0.00 sec)
  28.  
  29. mysql> desc kids;
  30. +-------+---------+------+-----+---------+-------+
  31. | Field | Type | Null | Key | Default | Extra |
  32. +-------+---------+------+-----+---------+-------+
  33. | id | int(11) | YES | | NULL | |
  34. +-------+---------+------+-----+---------+-------+
  35. 1 row in set (0.00 sec)
  36.  
  37. mysql> desc article_threads;
  38. +-------------+--------------+------+-----+---------+-------+
  39. | Field | Type | Null | Key | Default | Extra |
  40. +-------------+--------------+------+-----+---------+-------+
  41. | topic_id | int(11) | YES | UNI | NULL | |
  42. | category_id | int(11) | YES | MUL | NULL | |
  43. | filename | varchar(55) | NO | PRI | | |
  44. | author_name | varchar(100) | YES | | NULL | |
  45. | statusFlags | varchar(5) | YES | | NULL | |
  46. | discussion | int(11) | YES | | NULL | |
  47. | slug | varchar(255) | YES | UNI | NULL | |
  48. +-------------+--------------+------+-----+---------+-------+
  49. 7 rows in set (0.00 sec)
Add Comment
Please, Sign In to add comment