When retrieving associated models in findAll(), what is the reason cake
issues a separate SELECT for each associated record (versus reading
them all with a single JOIN query)?

For example, here is a snippet of my sql debug output for a "Product
hasMany Subproduct" association. You can see for each product_id, a
separate SELECT statement was issued on Subproduct, when a single JOIN
could have read them all at once.

Is this done for scalability reasons?

SELECT `Subproduct`.`id`, `Subproduct`.`product_id`,
`Subproduct`.`name`, `Subproduct`.`price`, `Subproduct`.`weight`,
`Subproduct`.`quantity`, `Subproduct`.`sort`, `Subproduct`.`created`,
`Subproduct`.`modified`, `Subproduct`.`description`,
`Subproduct`.`max_adults` FROM `subproducts` AS `Subproduct` WHERE
`Subproduct`.`product_id` = '10' ORDER BY `Subproduct`.`sort` ASC

SELECT `Subproduct`.`id`, `Subproduct`.`product_id`,
`Subproduct`.`name`, `Subproduct`.`price`, `Subproduct`.`weight`,
`Subproduct`.`quantity`, `Subproduct`.`sort`, `Subproduct`.`created`,
`Subproduct`.`modified`, `Subproduct`.`description`,
`Subproduct`.`max_adults` FROM `subproducts` AS `Subproduct` WHERE
`Subproduct`.`product_id` = '11' ORDER BY `Subproduct`.`sort` ASC

SELECT `Subproduct`.`id`, `Subproduct`.`product_id`,
`Subproduct`.`name`, `Subproduct`.`price`, `Subproduct`.`weight`,
`Subproduct`.`quantity`, `Subproduct`.`sort`, `Subproduct`.`created`,
`Subproduct`.`modified`, `Subproduct`.`description`,
`Subproduct`.`max_adults` FROM `subproducts` AS `Subproduct` WHERE
`Subproduct`.`product_id` = '12' ORDER BY `Subproduct`.`sort` ASC


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to