I'm Brett Slatkin and this is where I write about programming and related topics. Check out my favorite posts if you're new to this site. You can also contact me here or view my projects.

01 July 2013

Lazy-loading is the ORM anti-pattern

The creator of SQLAlchemy on async operation:

ORMs are poorly suited for explicit asynchronous programming, that is, where the programmer must produce explicit callbacks anytime something that uses network access occurs. A primary reason for this is that ORMs make extensive use of the lazy loading pattern, which is more or less incompatible with explicit async.

I could not disagree more. App Engine's NDB library is amazing at async. It was designed by Guido and likely was the inspiration for PEP 3156. It is the best ORM I have ever used. It enables refactoring and performance optimization.

I like and use SQLAlchemy, but the real takeaway here is lazy-loading is an anti-pattern.
© 2009-2016 Brett Slatkin