CakePHP 2.0 Rant Retraction CakePHP 2.0 Rant Retraction

In yesterday's article, it appears I may have misunderstood something regarding lazy loading.  I incorrectly read it as "loading the data" on-demand oppose to loading the object on-demand.  This actually looks like a great feature, especially after reading this: http://bakery.cakephp.org/articles/Frank/2010/08/10/optimizing-model-loading-with-lazymodel

It appears associated models would automatically be loaded simply because they are related to the model you are querying, even if you are not retrieving data from it.

Thanks for the clarification on lazy loading Jose and I'm actually quite excited to see this change after further research into the situation.  Check out these benchmarks from the above mentioned article:

Before lazy loading

Total Requests made: 100

Total Time elapsed: 6.8480186462402 (seconds)

Requests/Second: 14.603 req/sec

Average request time: 0.068 seconds

Standard deviation of average request time: 0.002

Longest/shortest request: 0.078 sec/0.066 sec

Memory usage: 9.75MB

Post lazy loading

Total Requests made: 100

Total Time elapsed: 4.8957378864288 (seconds)

Requests/Second: 20.426 req/sec

Average request time: 0.049 seconds

Standard deviation of average request time: 0.001

Longest/shortest request: 0.056 sec/0.048 sec

Memory usage: 7.25MB

Almost 6 full requests more per second!  Just in the 100 requests made there is over 2 seconds being gained!  Excellent work community!

Published on Feb 1, 2011

Tags: CakePHP Tutorial | lazy loading

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.

Tutorials

Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.