mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
This will log any N+1 it finds, pointing to the line causing it and a way to solve it, aka. which `#includes` to add. Like so ``` web_1 | GET /admin/order_cycles.json?ams_prefix=index&q%5Borders_close_at_gt%5D=Sun+Jan+31+2021+00:00:00+GMT%2B0100+(Central+European+Standard+Time) web_1 | USE eager loading detected web_1 | OrderCycle => [:coordinator] web_1 | Add to your query: .includes([:coordinator]) web_1 | Call stack web_1 | /usr/src/app/app/serializers/api/admin/index_order_cycle_serializer.rb:41:in `coordinator' web_1 | /usr/src/app/app/controllers/spree/admin/base_controller.rb:98:in `render_as_json' web_1 | /usr/src/app/app/controllers/admin/order_cycles_controller.rb:17:in `block (2 levels) in index' web_1 | /usr/src/app/app/controllers/admin/order_cycles_controller.rb:14:in `index' web_1 | bin/rails:4:in `require' web_1 | bin/rails:4:in `<main>' ``` We gave a try at Bullet long ago and abandoned it because it's not a silver bullet (pun intended) due to false positives. However, it's pretty clear that this won't happen often; we have endless N+1 still to fix. I recently experienced how, relying on Bullet made it just extra 30s to fix additional N+1s other than the one I was fixing. Usually, finding the culprit line takes me more of 30min.