Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
References
Background
We've been ignoring what the Bullet gem reports for at least 6 years (maybe more), but we were still updating the gem and maintaining the code in
config/environments/
(which caused conflicts every time we runrails app:update
to upgrade to a new Rails version). Maintaining it isn't a huge effort, but it's infinitely bigger than the benefits we get from it, which are zero.Adding
includes
everywhere we query for records would be a huge maintenance effort and would make the code less readable, so I don't think it's worth it. We might do it occasionally if we detect a performance bottleneck.We could also use a gem to automatically avoid the N+1 queries problem, like Goldiloader, ArLazyPreload or JitPreload. Benchmarks show that the performance improvements obtained by using these gems is about less than 10% (it depends a lot on the page being loaded, though), which IMHO doesn't justify adding yet another gem that patches ActiveRecord and that could be incompatible with other gems doing so.
Objectives
rails app:update
and check the differences in theconfig/environments/development.rb
andconfig/environments/test.rb
filesNotes
There are a couple of open pull requests (at the time of writing, they've been open for about two years) in the Rails repository (rails/rails#45231 and rails/rails#45413) to automatically avoid N+1 queries as well. For now, we'll hope something similar is integrated in Rails itself in the future.