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.

GET /orders9 queries14.6 ms in SQL0 slow
  1. 1Order Load4.2 msSELECT "orders".* FROM "orders" WHERE "orders"."user_id" = ? ORDER BY "orders"."created_at" DESC LIMIT ?
  2. 2User Load0.8 msSELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ?
  3. 3Customer Load1.4 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  4. 4Customer Load1.2 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  5. 5Customer Load1.3 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  6. 6Customer Load1.1 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  7. 7Customer Load1.2 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  8. 8Customer Load1.3 msSELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ?N+1
  9. 9ShippingRate Load2.1 msSELECT "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.

A fictitious 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.

What the whole profiler adds per request, measured with the gem's own script/bench/request_overhead.rb on Ruby 3.4.6 (synthetic page, two runs). Full mode grows further with the number of method calls of a real page. Ruby 3.3 was not measured.
Function profilingAdded per request
Off5.3 to 5.8 ms
Lite, with stackprof6.1 to 6.4 ms
Full12.9 to 13.4 ms
A fictitious flame graph of the same page. Overhead figures come from the gem's README.

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%
Cache reads of the request
KeyResultTime
views/orders/index/user-1042HIT0.4 ms
views/orders/_order/order-58213HIT0.3 ms
views/orders/_order/order-58207MISS0.6 ms
pricing/zone-eu/2026-10HIT0.3 ms
views/orders/_order/order-58199MISS0.5 ms
Fictitious keys: two order partials missed, so the hit rate sits under 80%.

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 sView Job

Job profile

ReportExportJobFailed2.84 s

Triggered by POST /reportsView

  • Exception
  • Job
  • Database
  • Cache
  • Timeline
  • Env

ActiveRecord::RecordNotFound: Couldn't find Account with 'id'=7731

A fictitious export job queued by 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.

The test application's home page with the debug toolbar along the bottom: GET 200 in 326 ms, 7 database queries, 3 views, a cache hit rate of 84.62%, 1 outbound HTTP call, 7 dumps, 1 log, the route, a translation warning, 5 jobs with 1 failure, 1 mail, 61 environment variables, a Health item and the Profiler link.
The debug toolbar at the bottom of a page: the request's status and time, then a summary of each collector, red when something is wrong.
The dashboard at /_profiler, on its HTTP Requests tab, next to the Background Jobs, Console, Tests, Test Runner, Outbound HTTP and Env tabs. A table lists the latest requests with time, method, path, duration, number of queries, allocations, status and token: GET /api/n_plus_one ran 26 queries, GET /api/external_http_bodies took 731 ms, POST /jobs/failing and POST /jobs/nested answered 200.
The dashboard: every profiled request, with filters for slow requests, many queries, errors and exceptions, and a tab for jobs, console expressions and tests.
The Database tab of the profile of GET /api/n_plus_one: 26 database queries, a warning of a potential N+1 with one pattern repeated 25 times, the first query on posts, then the author lookups one by one, each flagged N+1.
The Database tab of a request that loads each post's author one query at a time: 26 queries, and the 25 identical ones flagged as an N+1.
The Timeline tab of the profile of GET /api/external_http_bodies: 4 events in 722 ms, the controller action as one bar and under it three outbound HTTP calls, a POST, a PATCH and a PUT to jsonplaceholder.typicode.com, then the function profiling table.
The Timeline tab: the controller action, and under it the three outbound HTTP calls it waited for, followed by the function profile.
The Cache tab of the profile of GET /api/cache_intensive: 14 reads, 10 writes, 1 delete and a hit rate of 71.43%, then the cache reads in order, the first four, on keys never written, marked MISS, followed by reads marked HIT.
The Cache tab: reads, writes and deletes, the hit rate, and each read with its key and whether it hit or missed.
The profile of a failed background job: FailingJob, failed after 125 ms, triggered by POST /jobs/failing with a link back to the request. Its Exception tab shows RuntimeError, Simulated job failure for profiler testing, and the application frame app/jobs/failing_job.rb:17.
A failed job opens on its Exception tab, with the request that queued it one link away.