I. There should not be a case where you have to load so many models in a single controller. As all objects in OOP, it is good that controllers be delegated only one specific task, not 2, not 3 and not 25...
Are you sure that there is no way that you can extract so functionality and move it to another controller for example?
II. You are using too much deep associations. I can see that you have a lot of 'Model groups' which are connected like:
- 'Photo', 'PhotoFavorite', 'PhotoLike', 'PhotoRating', 'PhotoComment'
- 'Blog', 'BlogComment', 'BlogFavorite', 'BlogLike'
- 'Group', 'GroupFavorite', 'GroupDiscussion', 'GroupMember', 'GroupPhoto', 'GroupLike', 'GroupComment'
These lead to a loot of data being fetched. Especially if you have the $recursive property of the 'caller' model set to 2. So for example:
if you try to get 10 records from 'Blog' you will also get all the 'BlogComments' for each of those 10 and all the 'BlogFavorites' for each of those 10.
If you had another 'join model' it could be even worse like: 1 Blog has 1000 Comments, each Comment has 10 BlogCommentLikes .....
You can see how quickly this grows into a problem. It is very important to understand that this is not an bug but a tradeoff. This is so because of the Model Associations in the current Cake "ORM". Actually when you understand it it will not be an issue - you just have to cope with it.
On Monday, 30 June 2014 10:33:29 UTC+3, Chris wrote:
-- Are you sure that there is no way that you can extract so functionality and move it to another controller for example?
II. You are using too much deep associations. I can see that you have a lot of 'Model groups' which are connected like:
- 'Photo', 'PhotoFavorite', 'PhotoLike', 'PhotoRating', 'PhotoComment'
- 'Blog', 'BlogComment', 'BlogFavorite', 'BlogLike'
- 'Group', 'GroupFavorite', 'GroupDiscussion', 'GroupMember', 'GroupPhoto', 'GroupLike', 'GroupComment'
These lead to a loot of data being fetched. Especially if you have the $recursive property of the 'caller' model set to 2. So for example:
if you try to get 10 records from 'Blog' you will also get all the 'BlogComments' for each of those 10 and all the 'BlogFavorites' for each of those 10.
If you had another 'join model' it could be even worse like: 1 Blog has 1000 Comments, each Comment has 10 BlogCommentLikes .....
You can see how quickly this grows into a problem. It is very important to understand that this is not an bug but a tradeoff. This is so because of the Model Associations in the current Cake "ORM". Actually when you understand it it will not be an issue - you just have to cope with it.
On Monday, 30 June 2014 10:33:29 UTC+3, Chris wrote:
hi guys,.. I'm using to many cross tables in a controller,... and getting memory error not enough bites,...var $uses = array('User', 'Friend', 'FriendRequest', 'UserInvisiblePoint', 'UserStatusPost', 'StatusLike', 'StatusNotification', 'ZodiacType', 'Point', 'ProfileComment', 'Gift', 'Guest', 'Resume', 'UserBan', 'Invitation', 'Report', 'Photo', 'PhotoFavorite', 'PhotoLike', 'PhotoRating', 'PhotoComment', 'Blog', 'BlogComment', 'BlogFavorite', 'BlogLike', 'Group', 'GroupFavorite', 'GroupDiscussion', 'GroupMember', 'GroupPhoto', 'GroupLike', 'GroupComment', 'Dba', 'DbaFavorite', 'DbaLike', 'Video', 'VideoFavorite', 'VideoLike', 'VideoComment', 'Classified', 'Event', 'Notification', 'ProfileNotification', 'Bookmark', 'Message', 'Alert', 'Signin', 'Signin');how can I avoid this doing from "user.php" model,...?thanks in advance,...
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment