Commit df5e99c4 authored by David Négrier's avatar David Négrier

Updating smart eager loading existing implementations

parent a4e83633
Pipeline #93376 passed with stages
in 5 minutes and 43 seconds
......@@ -6,19 +6,28 @@ lang: en
theme: main
#menu: Foo/Bar
context:
post_date: 2019-09-06
post_date: 2019-09-21
introduction: In this article, I present a new way to deal with the N+1 issue that we are facing when using most ORMs.
related:
- /tdbm5.1-symfony-tutorial
- /tdbm5.1-rich-model
- /tdbm5-coming-out
# update_date: 2017-11-21
update_date: 2019-09-21
---
I'm an ORM developer. If you are not aware, I'm involved in the development of [TDBM, a DB-first PHP ORM](https://thecodingmachine.github.io/tdbm/).
As anyone developing an ORM, I came to face the dreaded N+1 performance problem. I believe we came with an elegant solution
to this issue and I wanted to share that with the wider community (other ORM developers might be interested!)
<div class="alert alert-info"><strong>Update:</strong> I've had a lot of feedback from the community (thanks everybody, you are wonderful!)
telling me this idea has already been implemented in various ORMs. Here is a quick list:
<ul>
<li><em><a href="https://github.com/nette/database#database-explorer" target="_blank">Nette Database Explorer</a></em> already implements the pattern I describe</li>
<li><em><a href="https://github.com/liam-wiltshire/laravel-jit-loader" target="_blank">Laravel JIT loader</a></em> implements this pattern for Eloquent (they called it "lazy eager loading")</li>
<li><em><a href="https://datamapper.org/why.html" target="_blank">DataMapper</a></em> (a Ruby ORM) calls this feature "Strategic Eager Loading"</li>
</ul></div>
## The N+1 problem
ORMs are tools that write SQL requests for you. Because you use a nice object model instead of writing SQL, it is easy not
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment