Performance: N+1 detection tools
HIGH IMPACT
This concept affects page load speed by reducing unnecessary database queries that delay content rendering.
posts = Post.includes(:author).all posts.each do |post| puts post.author.name end
posts = Post.all posts.each do |post| puts post.author.name end
| Pattern | Database Queries | Server Processing | Page Load Delay | Verdict |
|---|---|---|---|---|
| N+1 queries | N+1 queries (one per item) | High CPU and wait time | Delays LCP significantly | [X] Bad |
| Eager loading with includes | 2 queries (one for main, one for associations) | Low CPU and wait time | Faster LCP | [OK] Good |