Can you show your use of containable?
I think something might be amiss...

On Nov 5, 6:21 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> After a bit of digging setting the 'recursive' property in the model
> _partially_ solves this:
> var $actsAs = array('Containable' => array('recursive' => false));
>
> However, obviously won't help where some items need a 2nd or 3rd
> level.
>
> So I guess it comes back to: is there any way to be model-specific for
> recursion?
>
> On Nov 5, 2:54 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > That's the problem with 'contain' though ... even if I do use a hasOne
> > bind, 'contain' will still do extra queries.
> > In the example I mentioned, it will retrieve everything properly in 1
> > big query, but then it'll go back again and find the models listed in
> > 'contain'.
> > On a default page of 20 records (since I'm doing pagination), where
> > each record has 4 extra models to find you're looking at 80 extra
> > unnecessary db hits ... multiply that by X users view the page and
> > you're looking at a lot of unnecessary queries. Sure it's just
> > milliseconds, but still quite concerning.
>
> > On Nov 5, 2:48 pm, teknoid <[EMAIL PROTECTED]> wrote:
>
> > > JOINS are only built for hasOne and belongsTo relationships.
> > > A bunch of little selects will not harm your DB (how many milliseconds
> > > do those queries take?)
>
> > > Are you displaying some list on the page? Maybe paginate is in order
> > > for this case?
>
> > > All that being said, if you are not happy with that and prefer a long
> > > JOIN query, you can always "trick" cake into building one, by using a
> > > temporary hasOne bind.
>
> > > On Nov 5, 5:08 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > > What might also help is a way to include recursion on only certain
> > > > associations - which can be done with 'contain', but again, 'contain'
> > > > is doing more db queries than it needs to.
>
> > > > On Nov 5, 11:38 am, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > > > This is getting quite confusing/frustrating ...
>
> > > > > If I use 'contain' it's the equivalent of using 'unbind' (on the fly)
> > > > > on everything not listed in 'contain' (as described in the Cookbook);
> > > > > however, if I use 'contain', it seems to actually execute an extra
> > > > > query to get that corresponding information, regardless of association
> > > > > type.
>
> > > > > For example, list of members with countries (belongsTo), provinces
> > > > > (belongsTo), plus a whole bunch of other stuff: webpages, interests,
> > > > > etc.
>
> > > > > If I'm doing a listing, I just want name, country, and province, so I
> > > > > can either do unbind on everything I don't need, or use 'contain' on
> > > > > the things I do need .... 'contain' is the logical choice.
> > > > > The resulting query does a LEFT JOIN on countries and provinces just
> > > > > fine, but it ALSO does an extra query for every single country_id and
> > > > > province_id to get the name. So on a big long list I'm getting quite a
> > > > > few extra database hits.
>
> > > > > Is this supposed to do this? Because it goes against the Cookbook's
> > > > > comment of "Using Containable will help you cut down on needless wear
> > > > > and tear on your database".
>
> > > > > (This gets slightly worse once I go a level deeper.)
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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