In this post, I illustrate how I usually try to avoid N+1 queries. — The most significant bottleneck in web applications typically lies within the databases. Therefore, the goal is to minimize the number of queries made, especially inside loops, as much as possible. There are exceptions though, like running a one-time script to clean some data. Here’s an example that I’m working on: …