I assume the DB engine will make the right decisions, but just wanted to make sure...
posts
id, title
comments
id, text, post_id
Querying for comments with posts with a title of xxx:
SELECT * FROM posts, comments 
WHERE posts.id = comments.post_id 
AND posts.title = 'xxx';
Does it:
A: first join both tables and the filter by title
or
B: Get post ids, then filter comments by those ids, then join
I hope and expect it to be B, which would resolve above query to:
- SELECT id, title FROM posts WHERE title = 'xxx'; // save id and title, create ids array from all rows
- SELECT * FROM comments WHERE post_id IN ids
- jointhe result of 2. with the- titlesof- 1.
 
     
    