Here is my simplified database:
user_post
- id
- post_id (FK)
post
- id
- link_id (FK)
link
- id
I've a list of user_post
and I wanna get for each of them the link
they are linked to.
Currently, I'm doin it like this:
SELECT userPost.post.link FROM UserPost userPost WHERE userPost IN (:userPosts)
Works great, but maybe later, I'll get a huge number of user_post
, so there'll be a lot of values within the IN
clause (100 < x < 5000+).
Is IN
limited? Is there any other way to do it? Before, I was doin it like this:
for (UserPost userPost : user.getUserPosts()) {
Link link = userPost.getPost().getLink();
//
}
But the solution above takes really a lot of time to get executed, so I'm lookin for a more optimized one.