2011-05-07 94 views
1

我正在使用Rails 3.0.7,kaminari寶石。頁面索引需要太多時間來加載

我剛剛建立了一個簡單的網站,使用SQLite數據庫和數據的100,000行,只有四列(IDnamecreated_atupdated_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) 

我不知道爲什麼名單了這麼久纔回應...我應該怎麼解決呢?謝謝!

+0

時間主要花在視圖上。你是否在索引頁面的循環中使用partials?在開發模式下,這可能會在較慢的機器上花費很多時間。 – Thilo 2011-05-10 13:44:58

+0

該視圖很簡單,只是一個「ol」列表。沒有偏見。 – Victor 2011-05-11 02:03:21

回答

0

該日誌是從全新的rails重新啓動輸出還是應用程序已經運行了幾個請求?

如果這不是第一個請求,我會檢查每個請求的加載時間是否增加。

如果是這樣,您可能有內存泄漏

相關問題