Thank you both for your help! I tend to using 2 select-statements,
because the most frequent use case will be a user who views the
overview-page (containing several blog posts, possibly summarized) and
then selecting a specific one to read, including comments. Thus, the
blog post will most
Martin wrote:
a) 2 separate select-queries? One query going like:
SELECT * from blog_posts WHERE post_id = my_post_id
and the other sth. like
SELECT * from comments WHERE parent_id = my_post_id.
b) one join-query? Joining the two tables over my_post_id, so I only
need 1 sql-query?
Two
the traditional wisdom is that the join is faster, because you have
fewer round trips to the database. particularly if you are loading
many parent items each with many child items. if you are loading just
a single parent item, the second SELECT to get its child items is not
a very large hit at