Select N+1 problems

You may have heard of select N+1 problems before. It's the name for a class of performance problems that relate to inefficient querying of a DB. The pathological case is where you query one table for a list of items and then query another table to get the details for each item, one at a time. This is where the name comes from. Instead of the single query required, you perform N queries (one for the details of each item) and one query to get the list to begin with. Perhaps a better name would be select 1+N. The example at the end of the Latency section (earlier in this chapter) illustrates a select N+1 problem.

You will hopefully not write such bad-performing queries by hand, but an O/RM can easily output very inefficient ...

Get ASP.NET Core 2 High Performance - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.