Page index takes too much time to load
I am usi开发者_JAVA百科ng Rails 3.0.7, kaminari gem.
I just built a simple site, with SQLite database and 100,000 rows of data, with just four columns (ID
, name
, created_at
, updated_at
).
This is my controller:
class HclinksController < ApplicationController
# GET /hclinks
# GET /hclinks.xml
def index
@hclinks = Hclink.page(params[:page])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @hclinks }
end
end
end
I scaffolded it.
Here's my log:
// THIS IS INDEX, WHICH SHOWS ALL THE LIST ITEMS
Started GET "/hclinks" for 127.0.0.1 at 2011-05-08 00:59:52 +0800
Processing by HclinksController#index as HTML
Hclink Load (391.8ms) SELECT "hclinks".* FROM "hclinks" LIMIT 25 OFFSET 0
SQL (4574.8ms) SELECT COUNT(*) FROM "hclinks"
Rendered hclinks/index.html.erb within layouts/application (178778.1ms)
Completed 200 OK in 182775ms (Views: 175845.5ms | ActiveRecord: 4966.6ms)
// THIS IS THE RUBY ON RAILS WELCOME PAGE
Started GET "/hclinks" for 127.0.0.1 at 2011-05-08 01:03:13 +0800
Processing by HclinksController#index as HTML
Hclink Load (65.3ms) SELECT "hclinks".* FROM "hclinks" LIMIT 25 OFFSET 0
SQL (910.6ms) SELECT COUNT(*) FROM "hclinks"
Rendered hclinks/index.html.erb within layouts/application (1532.2ms)
Completed 200 OK in 1657ms (Views: 652.5ms | ActiveRecord: 975.9ms)
I wonder why the list took so long to respond... How should I fix it? Thanks!
Is this log output from a fresh restart of rails or had the app already run a few requests?
If this wasn't the first request, I'd check if the load time increases on each request.
If it does, you may have a memory leak
精彩评论