1
我正在使用Rails 3.0.7,kaminari宝石。页面索引需要太多时间来加载
我刚刚建立了一个简单的网站,使用SQLite数据库和数据的100,000行,只有四列(ID
,name
,created_at
,updated_at
)。
这是我的控制器:
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
我脚手架它。
这里是我的日志:
// 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)
我不知道为什么名单了这么久才回应...我应该怎么解决呢?谢谢!
时间主要花在视图上。你是否在索引页面的循环中使用partials?在开发模式下,这可能会在较慢的机器上花费很多时间。 – Thilo 2011-05-10 13:44:58
该视图很简单,只是一个“ol”列表。没有偏见。 – Victor 2011-05-11 02:03:21