I am using Yii framework and I have a Post that has many comments, I need to get a list of posts, and each post should hold the latest 5 comments with it.
- First Option: Is to make a join between posts and comments table and in the PHP code I should normalize the posts list to remove the duplicates and put the commets inside each related post.
- Second Option: Is to load the posts list, then in PHP code iterate over these posts list and load the comments for each post using a separate sql hit.
Which one has the best performance and is there any better way to do it?