hi alex

On Tue, July 13, 2010 11:57 am, Alex Bovey wrote:
> Well, my debug level is 0 for production but since I can't see the SQL log
> I'm turning it to 2 for debugging.
>
> Can I get cake to log the SQL somewhere and still set debug to 0?
>
> Interestingly I found this, which seems to imply that Containable is the
> cause of the problem, rather than the solution:
>
> http://www.endyourif.com/cakephp-containable-statement-pitfalls/
>
> Indeed if I stop using containable and instead set recursive to 0 or 1, I
> get fewer queries.
>
> Hmm, maybe it's time to start writing custom queries?

refining by writing custom queries can be useful but having found an issue
recently where repeated custom queries were stealing memory and not being
cleared by garbage collection, i'd be a bit wary of this as a solution.

if you do have issues with lots of queries, then you might also be worth
looking at view/ object caching if they are having performance issues on
your application.

you'd also be worth moving up to a more recent version of cake1.2 as the
recent code releases are more optimised than the version you are using.

mikek


>
> On Tue, Jul 13, 2010 at 10:58 AM, Jeremy Burns | Class Outfit <
> jeremybu...@classoutfit.com> wrote:
>
>> Out of interest, what is your debug level?
>>
>> Jeremy Burns
>> *Class Outfit*
>> *
>> *
>> jeremybu...@classoutfit.com <jeremybu...@mac.com>
>> http://www.classoutfit.com
>>
>> On 13 Jul 2010, at 10:57, Alex Bovey wrote:
>>
>> Hi Nick,
>>
>> Thanks for the reply.
>>
>> Sorry I should have said in my original post - I'm already using
>> Containable AND setting recursive to -1 in app_model.php.
>>
>> But still the selects are incredibly inefficient - a single query to
>> fetch
>> each individual row?!
>>
>> I'm not specifying 'fields' but surely that's not going to mean the
>> difference between what should be 2 queries at most, and the thousands
>> I'm
>> ending up with...
>>
>> Thanks,
>>
>> Alex
>>
>> On Tue, Jul 13, 2010 at 9:59 AM, nurvzy <nur...@gmail.com> wrote:
>>
>>> Use a mixture of:
>>>
>>> fields option key (so you're not retrieving data you don't intend to
>>> use),
>>> containable (so you're not selecting associative models and their
>>> fields you don't care about),
>>> and set recursive = -1 in your app_model.php
>>>
>>> The first thing I do whenever I start any new CakePHP project is open
>>> up app_model.php and add actsAs = array('Containable') and recursive =
>>> -1.
>>>
>>> I suggest you take advantage of the containable component.  Read about
>>> it here:
>>> http://book.cakephp.org/view/474/Containable
>>>
>>> Hope that helps,
>>> Nick
>>>
>>> On Jul 13, 2:35 am, Alex Bovey <a...@bovey.co.uk> wrote:
>>> > Hi all,
>>> >
>>> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
>>> > queries in my app.
>>> >
>>> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
>>> >
>>> > A simple $this->Enquiry->find('all') results in one query to fetch
>>> the
>>> > enquiries, and then a separate query for every single Enquiry to
>>> fetch
>>> the
>>> > User for that Enquiry.
>>> >
>>> > When I have more complex model relations I'm ending up with over
>>> 10,000
>>> SQL
>>> > queries.
>>> >
>>> > What am I doing wrong?!
>>> >
>>> > Thanks,
>>> >
>>> > Alex
>>>
>>> Check out the new CakePHP Questions site http://cakeqs.org and help
>>> others with their CakePHP related questions.
>>>
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "CakePHP" group.
>>> To post to this group, send email to cake-php@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>>> more options, visit this group at
>>> http://groups.google.com/group/cake-php?hl=en
>>>
>>
>>
>>
>> --
>> Alex Bovey
>> Web Developer | Alex Bovey Consultancy Ltd
>> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
>> a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
>> PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google
>> Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> at http://groups.google.com/group/cake-php?hl=en
>>
>>
>>  Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google
>> Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>> more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>
>
> --
> Alex Bovey
> Web Developer | Alex Bovey Consultancy Ltd
> Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
> a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
> PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group
> at http://groups.google.com/group/cake-php?hl=en
>


-- 
Mike Karthauser
Managing Director - Brightstorm Ltd

Email: mi...@brightstorm.co.uk
Web: http://www.brightstorm.co.uk
Tel:  07939 252144 (mobile)
Fax: 0870 1320560

Address: 1 Brewery Court, North Street, Bristol, BS3 1JS

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to