An N + 1 query problem occurs when an initial query retrieves records, then a separate query runs for each record. Instead of one query to fetch related data, the application sends the initial query plus N more, often adding significant latency. section 7.3.2
When a persistence framework generates SQL behind the scenes, use a profiler to inspect the queries and their execution counts. A profiler’s query list can make repeated queries easier to spot than logs or a debugger. section 7.3.2
Figure 7.13 Even when working with a framework, the profiler can still intercept the SQL queries. This makes your investigation a lot easier because you can’t copy the query directly from the code as you can when using JDBC and native queries.
Shows how a profiler can intercept SQL generated by a framework. section 7.3.2




