Guest User

Untitled

a guest
Jan 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. checkin - around 13m records
  2. users - around 250k records
  3. friends - around 1.5m records
  4.  
  5. SELECT checkin_id, created_at
  6. FROM checkin
  7. WHERE (user_id IN (SELECT friend_id from friends where user_id = 1 and is_approved = 1) OR user_id = 1)
  8. ORDER by created_at DESC
  9. LIMIT 0, 15
  10.  
  11. id select_type table type possible_keys key key_len ref rows Extra
  12. 1 PRIMARY checkin index user_id,user_id_2 created_at 8 NULL 15 Using where
  13. 2 DEPENDENT SUBQUERY friends eq_ref user_id,friend_id,is_approved,friend_looku... PRIMARY 8 const,func 1 Using where
  14.  
  15. SELECT c.checkin_id, c.created_at
  16. FROM checkin c
  17. INNER JOIN friends f ON c.user_id = f.friend_id
  18. WHERE f.user_id =1
  19. AND f.is_approved =1
  20. ORDER BY c.created_at DESC
  21. LIMIT 0 , 15
  22.  
  23. id select_type table type possible_keys key key_len ref rows Extra
  24. 1 SIMPLE f ref PRIMARY,user_id,friend_id,is_approved,friend_looku... friend_lookup 5 const,const 938 Using temporary; Using filesort
  25. 1 SIMPLE c ref user_id,user_id_2 user_id 4 untappd_prod.f.friend_id 71 Using where
  26.  
  27. id select_type table type possible_keys key key_len ref rows Extra
  28. 1 SIMPLE f index_merge PRIMARY,user_id,friend_id,is_approved,friend_looku... user_id,friend_lookup 4,5 NULL 11 Using intersect(user_id,friend_lookup); Using wher...
  29. 1 SIMPLE c ref user_id,user_id_2 user_id 4 untappd_prod.f.friend_id 71 Using where
  30.  
  31. SELECT c.checkin_id, c.created_at
  32. FROM checkin c
  33. INNER JOIN friends f
  34. ON c.user_id = f.friend_id
  35. WHERE f.user_id = 1
  36. AND f.is_approved = 1
  37. ORDER by c.created_at DESC
  38. LIMIT 0, 15
Add Comment
Please, Sign In to add comment