Conceptual
Login

Log the SQL Your ORM Actually Sends Before You Tune Anything

An ORM writes SQL for you, and the SQL it writes is frequently not the SQL you pictured: extra columns, extra joins, a query fired inside a template loop, or the same lookup repeated once per row. Every ORM can print the statements it sends with timings, and a query-count toolbar or middleware shows them per request. Tuning an ORM call you have never seen the SQL for is guessing, and guesses usually add an index nothing will use.

Questions this Concept answers

  • Why is tuning an ORM call without reading its SQL usually guesswork?