Victor S
Victor S

Reputation: 5142

Rails, should I optimize my view or my queries?

If my Rails development console shows 'view completed in' a time that is much greater than the 'active record completed in' time frame, should I optimize my views, or queries?

Completed 200 OK in 8441ms (Views: 7277.3ms | ActiveRecord: 316.9ms)

Granted, both are horrendous but, the views take much longer to render... Is there a way I should consider re-writing the views vs. changing the way the queries are performed?

Upvotes: 0

Views: 136

Answers (1)

rjk
rjk

Reputation: 1472

In my opinion, you need to optimize your views. Even if you shaved half the time off your database queries, the page would still take over seven seconds to render!

Attack the problem with the biggest payoff. In this case, cutting your view time in half takes your page from seven seconds down to three seconds. That's a pretty big win.

As MBHNYC mentioned, you should also determine whether the time is spent in the views or in the controllers setting up the information for your views.

Upvotes: 1

Related Questions