[{"data":1,"prerenderedAt":77},["ShallowReactive",2],{"term-q\u002Fquery-optimization":3,"related-q\u002Fquery-optimization":60},{"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":54,"sitemap":55,"stem":58,"subcategory":6,"__hash__":59},"terms\u002Fterms\u002Fq\u002Fquery-optimization.md","Query Optimization",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",{},"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. The goal is to get the same data with far less work. The EXPLAIN command is your best friend.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Query optimization is the process of improving the performance of SQL queries. It involves analyzing execution plans (EXPLAIN ANALYZE), adding appropriate indexes, rewriting inefficient queries, avoiding SELECT *, minimizing N+1 patterns, and understanding how the query planner makes decisions. Both manual and automatic (optimizer) techniques are used.",[11,27,29],{"id":28},"when-youll-hear-this","When You'll Hear This",[16,31,32],{},"\"The dashboard query was taking 10 seconds — after query optimization it's under 100ms.\" \u002F \"Run EXPLAIN ANALYZE to see what the query planner is doing.\"",{"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","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.","advanced","md","q",{},true,"\u002Fterms\u002Fq\u002Fquery-optimization",[49,50,51,52,53],"Index","Explain Plan","N+1 Query","Eager Loading","Partitioning",{"title":5,"description":41},{"changefreq":56,"priority":57},"weekly",0.7,"terms\u002Fq\u002Fquery-optimization","4O8Mzd7vbpcyaVir-vy8gFm7rh3vl688rXOPG_uNZcA",[61,65,68,71,74],{"title":52,"path":62,"acronym":6,"category":40,"difficulty":63,"description":64},"\u002Fterms\u002Fe\u002Feager-loading","intermediate","Eager loading fetches all the related data you need upfront in one or two queries.",{"title":50,"path":66,"acronym":6,"category":40,"difficulty":42,"description":67},"\u002Fterms\u002Fe\u002Fexplain-plan","EXPLAIN shows you exactly how the database plans to execute your query — which indexes it uses, how many rows it scans, where it is slow.",{"title":49,"path":69,"acronym":6,"category":40,"difficulty":63,"description":70},"\u002Fterms\u002Fi","A database index is like the index in the back of a book. Without it, the database reads every single row to find what you want.",{"title":51,"path":72,"acronym":6,"category":40,"difficulty":63,"description":73},"\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":53,"path":75,"acronym":6,"category":40,"difficulty":42,"description":76},"\u002Fterms\u002Fp\u002Fpartitioning","Partitioning divides a huge table into smaller physical chunks while still appearing as one table to your queries.",1776518305093]