I was looking at this PHP DB library called NotORM and upon reading its docs, I have read about its stand on joins. The argument was basically the performance of a single SQL query with joins vs. using multiple select queries and then cross-referencing the results in the DB abstraction layer.
I have always known that single queries should always be better than using multiple queries so NotORM's idea was new to me. I'm not sure also this because it's only in NotORM that I saw this "feature".
I'd like to ask you guys about your opinion about this.
Which query is better and faster?
This...
SELECT application.*, tag.*
FROM application
LEFT JOIN application_tag ON application.id = application_tag.application_id
LEFT JOIN tag ON application_tag.tag_id = tag.id
ORDER BY application.id
versus...
SELECT * FROM application LIMIT 4;
SELECT * FROM application_tag WHERE application_id IN ('1', '2', '3', '4');
SELECT * FROM tag WHERE id IN ('21', '22', '23', '24');
Is this second method really practical?