Consider two tables linked in by the main_table_id:
http://www.zigdigital.com.br/download/descartar/Diagrama1121220131414.jpg
I can fetch data like:
SELECT `main_table`.* , `second_table`.*
FROM `main_table`
JOIN `second_table`
ON (`main_table`.`main_table_id` = `second_table`.`main_table_id`)
WHERE `main_table`.`main_table_id` = ?
AND `second_table`.`main_table_id` ?
Or I can do the same thing using two queries:
SELECT *
FROM `main_table`
WHERE `main_table_id` = ?
And a second queries:
SELECT *
FROM `second_table`
WHERE `main_table_id` = ?
For me the only difference is that I'm gonna fetch the data all at once in the first case, and in two different arrays in the second case.
But my doubt is: In server performance, which one is the best way to handle the case?