What Rails Profiler shows you, when you need it
Four everyday moments of debugging a Rails app, and the part of the profiler you open for each. Every request gets a profile, reached from the debug toolbar at the bottom of the page or from the dashboard at /_profiler.
Spot the N+1 hiding in a page's queries
The Database tab lists every SQL query of the request in order: its number, the model, the time it took and the SQL with the bind values replaced by ?. That last detail is what makes repetition visible. When the same parameterized query runs 3 times or more, the tab warns about an N+1, groups the pattern, highlights it and gives you the backtrace behind it.
A summary tops the list: total count, total duration, slow queries and cached ones. Anything above slow_query_threshold (100 ms by default) is marked in red. The Explain button shows a query's plan, for read-only queries only and in a transaction that is always rolled back.
Prefer to ask? The MCP server's analyze_queries tool gives an AI assistant the same reading of a request.
- 1Order Load4.2 ms
SELECT "orders".* FROM "orders" WHERE "orders"."user_id" = ? ORDER BY "orders"."created_at" DESC LIMIT ? - 2User Load0.8 ms
SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? - 3Customer Load1.4 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 4Customer Load1.2 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 5Customer Load1.3 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 6Customer Load1.1 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 7Customer Load1.2 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 8Customer Load1.3 ms
SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1 - 9ShippingRate Load2.1 ms
SELECT "shipping_rates".* FROM "shipping_rates" WHERE "shipping_rates"."zone" = ?
N+1: the same query ran 6 times, once per order, from app/views/orders/_order.html.erb:4.
GET /orders: one customer lookup per order. The six identical lookups are the N+1 the Database tab flags.Read where a request spends its time
The Timeline tab draws every instrumented event of the request as a flame graph: controller, views, partials, SQL, cache, outbound HTTP and your own blocks, each nested under what called it. Click a block to zoom in, scroll to zoom, drag to pan, hover for the name, duration and payload, and press Ctrl+F to highlight matching events.
Wrap any slow piece of code in Profiler.measure("pricing.quote") and it appears at its place in the hierarchy.
Below the events, function profiling shows which Ruby methods the request spent its time in. Lite mode samples with the stackprof gem, which you add to your Gemfile yourself; full mode traces every method call with a TracePoint, with allocations and memory per method.
Solid blocks are the controller, views and partials; dashed ones are SQL, cache and outbound HTTP; the heavy outline is a Profiler.measure block.
| Function profiling | Added per request |
|---|---|
| Off | 5.3 to 5.8 ms |
| Lite, with stackprof | 6.1 to 6.4 ms |
| Full | 12.9 to 13.4 ms |
See which cache reads hit and which missed
The Cache tab lists each key the request read, with a HIT or MISS badge and how long the read took. When a page you expected to be cached is still slow, this is where the miss shows up, key by key.
Its summary counts reads, writes and deletes and gives the hit rate, shown in green above 80%. Writes and deletes are counted there but not listed. The toolbar carries the same hit rate in its CACHE item, which only appears when the request read the cache.
- Reads
- 5
- Writes
- 2
- Deletes
- 0
- Hit rate
- 60%
| Key | Result | Time |
|---|---|---|
views/orders/index/user-1042 | HIT | 0.4 ms |
views/orders/_order/order-58213 | HIT | 0.3 ms |
views/orders/_order/order-58207 | MISS | 0.6 ms |
pricing/zone-eu/2026-10 | HIT | 0.3 ms |
views/orders/_order/order-58199 | MISS | 0.5 ms |
Follow a failed job back to the request that queued it
With config.track_jobs = true, the default, every ActiveJob and Sidekiq job gets a profile of its own: SQL, cache, outbound HTTP, logs and exceptions, its queue, its arguments (masked like request parameters), its status and its error.
A request that enqueued jobs lists them in its Jobs tab, mails sent with deliver_later included, with View Job to open each one. The job profile names the request or job that queued it under Triggered by, with a link back. A job that raised opens straight on its Exception tab, and the toolbar's JOB item turns red when a job of the page failed.
POST /reports, Jobs tab
ReportExportJobqueue defaultFailed2.84 sJob profile
ReportExportJobFailed2.84 s
Triggered by POST /reports
- Exception
- Job
- Database
- Cache
- Timeline
- Env
ActiveRecord::RecordNotFound: Couldn't find Account with 'id'=7731
POST /reports: it failed, so its profile opens on the Exception tab, one link away from the request.The same screens, on a real app
The illustrations above use made up requests. These are screenshots of the gem's own pages, taken on the test application of the project: a Rails 7.2 app with the gem installed, seeded with a few users and posts, calling a public test API for its outbound requests. Nothing in them is retouched.





