[sqlalchemy] Re: Join vs. 2 selects?

2007-08-20 Thread Martin
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

[sqlalchemy] Re: Join vs. 2 selects?

2007-08-17 Thread Alexandre CONRAD
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

[sqlalchemy] Re: Join vs. 2 selects?

2007-08-17 Thread Michael Bayer
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