I have a simple query that uses a subquery:
SELECT pictures.*
FROM pictures
WHERE pictures.user_id IN
(SELECT follows.following_id
FROM follows
WHERE follows.follower_id = 9)
ORDER BY created_at DESC LIMIT 5;
I am wondering, a) How can I remove the sub query and use JOINS instead and b) will there be a performance benefit in using JOINS instead of sub query?
(follows.following_id, follows.follower_id, pictures.user_id are all indexed)
Thanks