Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option unused_eager_loading_enable is not working if n_plus_one_query_enable is disabled #580

Open
viktorianer opened this issue Jun 11, 2021 · 0 comments

Comments

@viktorianer
Copy link

viktorianer commented Jun 11, 2021

We would like to use Prosopite for N+1 detections. For this, I configured Bullet in our project as follows:

  config.after_initialize do
      ...
      Bullet.n_plus_one_query_enable = false
      Bullet.unused_eager_loading_enable = true
      Bullet.counter_cache_enable = true
    end

With these settings, Bullet tells me to remove includes:

AVOID eager loading detected
  Candidate => [:master_data, ...]
  Remove from your query: .includes([:master_data, ...])

But if I do so, Prosopite correctly find this N+1 problem:

SELECT "master_data".* FROM "master_data" WHERE "master_data"."candidate_id" = ? LIMIT 1
...

And of course Bullet tells me correctly to add includes, when I change settings to Bullet.n_plus_one_query_enable = true:

Candidate => [:master_data, ...]
Add to your query: .includes([:master_data, ...])

It looks like the combination of

Bullet.n_plus_one_query_enable = false
Bullet.unused_eager_loading_enable = true

does not work.

Our Rails environment:

Docker ruby:2.7.3-slim-buster
rails 6.0.3.4
ruby 2.7.3p183

# Gemfile
gem "puma", "~> 5.0"
gem "pg", 
gem "bullet", "~> 6.1", ">= 6.1.4"

PS: maybe related to #481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant