Guest User

Untitled

a guest
May 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. SELECT nf.id, nf.uuid, nf.leader_id, nf.data, nf.created_at, nfr.read_at
  2. FROM notification_followers nf
  3. LEFT JOIN user_follows uf ON uf.leader_id = nf.leader_id AND uf.follower_id = 14 AND uf.follow_status = 'follow'
  4. LEFT JOIN notification_followers_read nfr ON nf.id = nfr.notification_followers_id AND nfr.follower_id = 14
  5. WHERE (nf.created_at > uf.created_at)
  6. ORDER BY nf.id DESC
  7. LIMIT 10
  8.  
  9. ALTER TABLE `notification_followers` ADD INDEX `nf_lid_ca_id_idx` (`leader_id`,`created_at`,`id`);
  10. ALTER TABLE `user_follows` ADD KEY`uf_fid_lid_fs_ca_idx` (`follower_id`,`leader_id`,`follow_status`,`created_at`)
  11. ALTER TABLE `notification_followers_read` ADD INDEX `nfr_fid_nfid_ra_idx` (`follower_id`,`notification_followers_id`,`read_at`);
  12.  
  13. SELECT nf.id, nf.uuid, nf.leader_id, nf.data, nf.created_at, nfr.read_at
  14. FROM notification_followers nf JOIN
  15. user_follows uf
  16. ON uf.leader_id = nf.leader_id AND uf.follower_id = 14 AND
  17. uf.follow_status = 'follow' LEFT JOIN
  18. notification_followers_read nfr
  19. ON nf.id = nfr.notification_followers_id AND nfr.follower_id = 14
  20. WHERE nf.created_at > uf.created_at
  21. ORDER BY nf.id DESC;
Add Comment
Please, Sign In to add comment