ORMs are powerful tools when it comes to persist an object model into a database. They often come with a complete set of operations to query back the said database as the same object model. But ORMs’ “magic features” might end up being badly translated into nasty low level queries, causing a database engine being overloaded and become slow over time.
Whether it does come from a wrong database design with missing keys and indexes, wrong object model design, or excessive ORM API usage (criterias with projections are not well known features), unoptimized queries might end up rising at some point. In that case, one of the techniques we deploy is drilling deep down the generated queries using explain plans to detect performance bottlenecks.