Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- checkin - around 13m records
- users - around 250k records
- friends - around 1.5m records
- SELECT checkin_id, created_at
- FROM checkin
- WHERE (user_id IN (SELECT friend_id from friends where user_id = 1 and is_approved = 1) OR user_id = 1)
- ORDER by created_at DESC
- LIMIT 0, 15
- id select_type table type possible_keys key key_len ref rows Extra
- 1 PRIMARY checkin index user_id,user_id_2 created_at 8 NULL 15 Using where
- 2 DEPENDENT SUBQUERY friends eq_ref user_id,friend_id,is_approved,friend_looku... PRIMARY 8 const,func 1 Using where
- SELECT c.checkin_id, c.created_at
- FROM checkin c
- INNER JOIN friends f ON c.user_id = f.friend_id
- WHERE f.user_id =1
- AND f.is_approved =1
- ORDER BY c.created_at DESC
- LIMIT 0 , 15
- id select_type table type possible_keys key key_len ref rows Extra
- 1 SIMPLE f ref PRIMARY,user_id,friend_id,is_approved,friend_looku... friend_lookup 5 const,const 938 Using temporary; Using filesort
- 1 SIMPLE c ref user_id,user_id_2 user_id 4 untappd_prod.f.friend_id 71 Using where
- id select_type table type possible_keys key key_len ref rows Extra
- 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...
- 1 SIMPLE c ref user_id,user_id_2 user_id 4 untappd_prod.f.friend_id 71 Using where
- SELECT c.checkin_id, c.created_at
- FROM checkin c
- INNER JOIN friends f
- ON c.user_id = f.friend_id
- WHERE f.user_id = 1
- AND f.is_approved = 1
- ORDER by c.created_at DESC
- LIMIT 0, 15
Add Comment
Please, Sign In to add comment