I agree mostly, although I don't think Cake would have to recieve all the data before resolving the relationship; it could simply use another query instead of a join and use the primary key of the last query (in fact it must already be doing something similar with hasMany relations since obviously you can't fetch many related rows in a join). I find the thought that joins hurt the performance more than a set of regular queries strange as well, but if there's a guy at a data center who sets up those architectures claiming that to be the case..
Ah well, I'm gonna test which option is the fastest of course. Right now I'm mostly curious if it is even possible or if I'd have to write a custom database handler :). On 17 mrt, 14:53, Greg Skerman <[email protected]> wrote: > I'm no expert, but wouldn't this move load from the mysql box to the web > server box as cake would need to resolve all the relationships after it has > retrieved the data? > > And while we're at it, wouldn't multiple queries on the database where 1 > would suffice further hurt performance at the database level? > > I would suggest keeping the joins, and then run the queries through mysql's > EXPLAIN command to see if you can optomize the indexes on your tables. > > then aggressively cache the returned data to reduce the amount of hits to > the database...especially on queries which are known to be slow, or on > highly trafficked but not often updated pages. > > On Thu, Mar 17, 2011 at 11:25 PM, Elte Hupkes <[email protected]> wrote: > > Is it possible to specify an option in Cake that will make it use only > > separate queries rather than joins? For example, in a has many > > association, fetch the parent record with a separate query rather than > > left-join it? > > > Someone I'm developing for is running MySQL in a cluster; and > > apparently the guys hosting it have told him that joins hurt > > performance, since the data is distributed over several data nodes and > > a join can require it to fetch data from several nodes. His idea: get > > rid of the joins and use separate queries instead. I myself am not yet > > sure how much of this is true (if you're getting the data anyway, does > > it matter if you do it in a separate query or let MySQL do it in a > > join?), but either way I am curious if it can be done. > > > -- > > Our newest site for the community: CakePHP Video Tutorials > >http://tv.cakephp.org > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help > > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > > [email protected] For more options, visit this group > > athttp://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
