Why Bullet Gem? For this Rails optimization, we'll focus on optimizing repeated SQL calls to retrieve objects associated with many relationships: N+1 queries problem. The solution to such an issue is an eager loading association. Unoptimized N+1 affected code takes a significantly longer time as N times additional SQL calls are needed. But, we should be careful when using that eager loading approach. This because unused eager loading can deteriorate our Rails app performance instead of improving it. It's where the Bullet gem comes in handy. This gem will help us to find where
the N+1 queries problem is happening.
the eager loading associate is unused.
How to use Bullet Gem? This depends on the current application's state. In our case, we do these:
Add the bullet gem into Gemfile.
Define a new Rails environment called optimization.
Configure it to install the gem for that environment only
Run the Rails app with that environment
1. Add the Bullet gem into Gemfile. Here, we use its latest…
Score: 3.02
Privacy settings changed!
Article is saved. Do you want to continue editing the article or leave and edit later?