[{"data":1,"prerenderedAt":69},["ShallowReactive",2],{"term-l\u002Flazy-loading":3,"related-l\u002Flazy-loading":58},{"id":4,"title":5,"acronym":6,"body":7,"category":40,"description":41,"difficulty":42,"extension":43,"letter":44,"meta":45,"navigation":46,"path":47,"related":48,"seo":52,"sitemap":53,"stem":56,"subcategory":6,"__hash__":57},"terms\u002Fterms\u002Fl\u002Flazy-loading.md","Lazy Loading",null,{"type":8,"value":9,"toc":33},"minimark",[10,15,19,23,26,30],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"Lazy loading waits until you actually access related data before fetching it. Access post.author and only then does it query the database. Convenient, but if you do it in a loop it creates the N+1 problem automatically. Great for single records, terrible for lists.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Lazy loading defers the loading of related objects until they are explicitly accessed. It is the default behavior in many ORMs. While it reduces initial query complexity, accessing lazily-loaded relations inside a loop generates N+1 queries. It is appropriate when related data is rarely needed and the dataset is small.",[11,27,29],{"id":28},"when-youll-hear-this","When You'll Hear This",[16,31,32],{},"\"Lazy loading is convenient but caused N+1 queries in the list view.\" \u002F \"Switch from lazy to eager loading when rendering lists with related data.\"",{"title":34,"searchDepth":35,"depth":35,"links":36},"",2,[37,38,39],{"id":13,"depth":35,"text":14},{"id":21,"depth":35,"text":22},{"id":28,"depth":35,"text":29},"database","Lazy loading waits until you actually access related data before fetching it. Access post.author and only then does it query the database.","intermediate","md","l",{},true,"\u002Fterms\u002Fl\u002Flazy-loading",[49,50,51],"Eager Loading","N+1 Query","Query Optimization",{"title":5,"description":41},{"changefreq":54,"priority":55},"weekly",0.7,"terms\u002Fl\u002Flazy-loading","--gQv7c_E1-QmsoNNIb20j8mixh1q-iPT9XSdgiJEJ8",[59,62,65],{"title":49,"path":60,"acronym":6,"category":40,"difficulty":42,"description":61},"\u002Fterms\u002Fe\u002Feager-loading","Eager loading fetches all the related data you need upfront in one or two queries.",{"title":50,"path":63,"acronym":6,"category":40,"difficulty":42,"description":64},"\u002Fterms\u002Fn\u002Fn-1-query","N+1 is when your code runs 1 query to get a list of things, then runs 1 more query for EACH thing on the list.",{"title":51,"path":66,"acronym":6,"category":40,"difficulty":67,"description":68},"\u002Fterms\u002Fq\u002Fquery-optimization","advanced","Query optimization is the art of making slow database queries fast. Add an index here, rewrite that subquery as a JOIN, fetch only the columns you need.",1776518291827]