mito
mito copied to clipboard
Eager Loading should be with a JOIN not two queries
In the docs for eager-loading https://github.com/fukamachi/mito#eager-loading I noticed that the queries are:
;-> ;; SELECT * FROM `tweet` WHERE (`status` LIKE ?) ("%Japan%") [3 row] | MITO.DB:RETRIEVE-BY-SQL
;-> ;; SELECT * FROM `user` WHERE (`id` IN (?, ?, ?)) (1, 3, 12) [3 row] | MITO.DB:RETRIEVE-BY-SQL
But really this is inefficient since it's causing two queries, it should really be handled as a LEFT JOIN
to be one query instead of two and it should be:
SELECT * FROM `tweet` WHERE (`status` LIKE ?) ("%Japan%") LEFT JOIN `user` ON `user`.ID = `tweet`.ID;