{"action":"created","issue":{"url":"https://api.github.com/repos/CakeDC/search/issues/195","labels_url":"https://api.github.com/repos/CakeDC/search/issues/195/labels{/name}","comments_url":"https://api.github.com/repos/CakeDC/search/issues/195/comments","events_url":"https://api.github.com/repos/CakeDC/search/issues/195/events","html_url":"https://github.com/CakeDC/search/issues/195","id":81453281,"number":195,"title":"Significant slowdown when containing recursively","user":{"login":"eaxexe","id":517111,"avatar_url":"https://avatars.githubusercontent.com/u/517111?v=3","gravatar_id":"","url":"https://api.github.com/users/eaxexe","html_url":"https://github.com/eaxexe","followers_url":"https://api.github.com/users/eaxexe/followers","following_url":"https://api.github.com/users/eaxexe/following{/other_user}","gists_url":"https://api.github.com/users/eaxexe/gists{/gist_id}","starred_url":"https://api.github.com/users/eaxexe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eaxexe/subscriptions","organizations_url":"https://api.github.com/users/eaxexe/orgs","repos_url":"https://api.github.com/users/eaxexe/repos","events_url":"https://api.github.com/users/eaxexe/events{/privacy}","received_events_url":"https://api.github.com/users/eaxexe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-27T13:44:35Z","updated_at":"2015-05-27T13:56:46Z","closed_at":null,"body":"I have the following code in my controller:\r\n\r\n    $this->paginate = [\r\n            'contain' => ['Users', 'ProjectCategories', 'ParentProjects', 'Cities', 'Companies', 'ProjectStatuses'],\r\n            'order' => ['ProjectStatuses.identifier DESC']\r\n        ];\r\n        $this->Prg->commonProcess();\r\n\r\n        $companyId = $this->Auth->user('company_id');\r\n\r\n        $projects = $this->Projects->find('searchable', $this->Prg->parsedParams())->matching(\r\n            'Companies', function ($q) use ($companyId) {\r\n                return $q->where(['Companies.id' => $companyId]);\r\n            }\r\n        );\r\n\r\nAnd in my Projects Models' Initialize:\r\n\r\n     $this->belongsTo('ParentProjects', [\r\n            'className' => 'Projects',\r\n            'foreignKey' => 'parent_id'\r\n        ]);\r\n\r\nContaining the \"ParentProjects\" causes a significant slowdown on pageload.\r\nFrom ~3000 ms to ~108000 ms"},"comment":{"url":"https://api.github.com/repos/CakeDC/search/issues/comments/105921074","html_url":"https://github.com/CakeDC/search/issues/195#issuecomment-105921074","issue_url":"https://api.github.com/repos/CakeDC/search/issues/195","id":105921074,"user":{"login":"eaxexe","id":517111,"avatar_url":"https://avatars.githubusercontent.com/u/517111?v=3","gravatar_id":"","url":"https://api.github.com/users/eaxexe","html_url":"https://github.com/eaxexe","followers_url":"https://api.github.com/users/eaxexe/followers","following_url":"https://api.github.com/users/eaxexe/following{/other_user}","gists_url":"https://api.github.com/users/eaxexe/gists{/gist_id}","starred_url":"https://api.github.com/users/eaxexe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eaxexe/subscriptions","organizations_url":"https://api.github.com/users/eaxexe/orgs","repos_url":"https://api.github.com/users/eaxexe/repos","events_url":"https://api.github.com/users/eaxexe/events{/privacy}","received_events_url":"https://api.github.com/users/eaxexe/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T13:56:46Z","updated_at":"2015-05-27T13:56:46Z","body":"Right, sorry @antoniovassell :)\r\n\r\nIf I remove the 'searchable' behaviour in both the model and the controller, it is back to the \"right\" speed (@ ~3000 ms)\r\n\r\nI have \"solved\" the problem by simply not containing it (it wasn't needed anyway) but wanted to report the undesirable behaviour :)"}}