Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:30:59+00:00 2026-06-15T22:30:59+00:00

I’m working on a legacy CakePHP app built on the 1.3.x branch, which makes

  • 0

I’m working on a legacy CakePHP app built on the 1.3.x branch, which makes heavy use of the Containable behavior and specifically deep nested contains.

It has become apparent that this is a massive performance issue due to the way CakePHP framework handles the queries underneath deep contains. In one request we have over 10K queries followed by Cake merging the data together into an array.

Can anyone confirm if these issues are fixed in the Cake 2.x branch and by upgrading the framework we could make headway on performance issues.

Due to time constraints, we can currently either upgrade or tackle re-writing parts of the system to not use Containable, but not both.

I would prefer to upgrade as there are other benefits to be had, but I need to be sure that our performance issues will be tackled.

Example of deep nested contain

$this->Event->find('all', array(
        'conditions' => $conditions,
        'contain' => array(
            'SessionDay' => array(
                    'Activity' => array(
                     'TimeSlot' => array(
                        'TimeSlotBooking',
                            'order' => array('slot_time' => 'asc')
                    )
                    )
            ),
            'Activity' => array(
                'TimeSlot' => array(
                    'TimeSlotBooking',
                    'order' => array('slot_time' => 'asc')
                )
            ),
            'Interview' => array(
                'InterviewBooking',
                'order' => array('interview_time' => 'asc')
            ),
            'EventCode'
            )
        )
    );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:31:00+00:00Added an answer on June 15, 2026 at 10:31 pm

    I have been using very deep nested containable queries on a project with Cake 2.x and they work well.

    It still produces multiple queries and in some cases instead of doing

    SELECT * FROM table WHERE x IN (1,2,3)
    

    it will do:

    SELECT * FROM table WHERE x = (1)
    SELECT * FROM table WHERE x = (2)
    SELECT * FROM table WHERE x = (3)
    

    So you can end up with a lot of queries. At the end of the day it’s going to depend on how many rows you actually need to retrieve from all your tables.

    I’d suggest installing another Cake 2 project along side using the same database. Just quickly copy over your models and run your biggest query, then look at the difference in the query debug output for any differences.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
Specifically, suppose I start with the string string =hello \'i am \' me And
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have an autohotkey script which looks up a word in a bilingual dictionary
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.