Looks like you ran out of memory for that query. How many prodaccessories are you pulling? If it’s over 50 or so you should probably not use AR for this case
it like a couple of 100:s, but it works using regular lazy loading or with just the with() command then its sending back like 3000 rows. what is the outcome of using the together->false option I thought it would be an additional query much like when you use lazy loading ?
I guess I just have to touch the related models in the controller before I save them to the cache.
Can you say something about the speed difference between eager/lazy-loading? I’m just wondering does it take several seconds longer or is lazy-loading just marginal faster?
Thanks for all the answers, my model is more complicated then in my example … but there is a significant decrease in performance when using the eager loading approach.
What jonah said is pretty logic and that’s why I was asking about speed-difference. How you measure the performance? Note if you not access all relations, lazy-loading could be faster of course. Also in debug mode you will see a huge performance decrease when using many relations. Try to test in production mode in this case.
In actionViewProduct() you only retrieve one product without related data. Are you sure the view accesses all the related data? What are all the queries performed in each case? BTW, I don’t think caching helps anything with the way you are doing it. I don’t think the cache is faster than a DB query. Usually you use the cache to cache calculations performed, not just database rows