News Score: Score the News, Sort the News, Rewrite the Headlines

Abstraction boundaries are optimization boundaries

The N+1 query problem occurs when your application code sends one SQL query per element in a collection. The N queries are redundant; since all of the data is in the database already, a single query should be enough. This problem is usually caused by a leaky abstraction; the ORM, or whatever database abstraction you are using, can’t anticipate that it would need to send N queries, so it can’t automatically optimize this down to a single query. The solution is usually to move the abstraction boun...

Read more at blog.snork.dev

© News Score  score the news, sort the news, rewrite the headlines