Answer the question
In order to leave comments, you need to log in
Left join vs Multiple selects?
Which is better in terms of performance?
versusselect a left join b on b.id = a.b_id
select from a // (получили 1,2,3)
select from b where id = 1,2,3
Answer the question
In order to leave comments, you need to log in
one). Your "SQL" is more like pseudocode
2). These queries are not equivalent (read more about LEFT JOIN)
3). The first option is faster (under reasonable assumptions), the second is a well-known anti-pattern used by novice programmers who are frightened by "slow joins". In fact, joins are exactly what relational databases can do very quickly and very advanced.
I don't know about you, of course. But when I tested it on my database, it processes a request like:select from b where id in (select id from a)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question