loading localhost:3000/projectszzzzz takes forever to load > 2min

i have roughly 30 resources in routes, 10 scopes, a few nested resources. how can i find out what the problem is?

Turn your logging level up to debug, and watch the queries that are being generated by ActiveRecord in order to load this route. Are you seeing multiple requests to the database, or one big honking joined query? Sometimes using joins is slower than eager loading (which generally loads in two or more queries). But for slow, nothing beats an N+1 query, where you load a bunch of objects, then make a separate query or more per object to gather associated records from other related models.

Without any more details about your setup (running on a Raspberry Pi? or bouncing your database connection off the moon?) it's impossible to say. But start there.


Check the log, it tells you the time spent on each query to the database:

User Load (1.0ms) SELECT users.* FROM users WHERE users.id = 201356 LIMIT 1

Note that “1.0ms”

It also tells you how log it took to render the each view and the totals:

Rendered shared/_menu.html.slim (74.7ms)

Rendered shared/_footer.html.slim (251.1ms)

Rendered shared/_flash_modal.html.slim (2.7ms)

Completed 200 OK in 48109ms (Views: 45777.0ms | ActiveRecord: 1670.4ms)

You can also use gems like miniprofiler or bullet (for N+1 Queries) that shows you some of that information in a friendlier way



*It also tells you how long it took to render each view and the totals: