talira

Help to kill N+1 queries and unused eager loading

open sourceMITself-hostablefree

Bullet watches the queries a Rails app makes while you develop and tells you when to add eager loading (N+1 queries), when eager loading you added isn't used, and when a counter cache would save a COUNT query. It tracks the loading of associations in Active Record (4.0 and later) and Mongoid, and reports through the browser (alerts or the footer), the Rails log, its own log file, Sentry, Honeybadger, Slack and others. It can raise in tests, and you can allowlist known cases.

Problems it solves

  • warn me in the browser when a Rails page has an N+1 query
  • find eager loading I added that isn't actually used
  • tell me when a counter cache would save a COUNT query on every row
  • make the test suite fail when an N+1 query is introduced
  • send N+1 warnings from staging to Sentry or Slack
  • a Mongoid app is making one query per document in a loop
  • my Rails app is slow and I suspect it's loading associations one by one
  • list every place my app should add includes

Features

  • N+1 query detection
  • unused eager loading detection
  • counter cache suggestions
  • Active Record and Mongoid
  • browser alerts and footer
  • Rails log and bullet.log
  • notifiers for Sentry, Honeybadger, Slack and more
  • raise in tests
  • safelists

Alternatives

The same job

These do what Bullet does.

  1. Prosopite Rails N+1 queries auto-detection with zero false positives / false negatives
  2. Goldiloader Just the right amount of Rails eager loading

Compare Bullet with the top 3