這裏是我的服務器日誌裝入我的Dashboard#Index
行動:根據此服務器日誌,建議如何優化我的應用程序?
Started GET "/" for 127.0.0.1 at 2014-10-27 03:26:56 -0500
User Load (1.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Processing by DashboardController#index as HTML
FamilyTree Load (3.0ms) SELECT "family_trees".* FROM "family_trees" WHERE "family_trees"."user_id" = $1 LIMIT 1 [["user_id", 1]]
ReadMark Load (1.1ms) SELECT "read_marks".* FROM "read_marks" WHERE "read_marks"."user_id" = $1 AND "read_marks"."readable_type" = 'PublicActivity::ORM::ActiveRecord::Activity' AND "read_marks"."readable_id" IS NULL ORDER BY "read_marks"."id" ASC LIMIT 1 [["user_id", 1]]
Membership Load (1.3ms) SELECT "memberships".* FROM "memberships" WHERE "memberships"."user_id" = $1 LIMIT 3 [["user_id", 1]]
Rendered shared/_profile_box.html.erb (3.2ms)
Node Load (1.4ms) SELECT "nodes".* FROM "nodes" WHERE "nodes"."family_tree_id" = $1 AND "nodes"."is_comment" IS NULL [["family_tree_id", 1]]
User Load (1.5ms) SELECT "users".* FROM "users" INNER JOIN "memberships" ON "users"."id" = "memberships"."user_id" WHERE "memberships"."family_tree_id" = $1 ORDER BY "users"."first_name" ASC [["family_tree_id", 1]]
Rendered shared/_upload.html.erb (13.2ms)
User Load (1.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
Video Load (1.3ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" = $1 LIMIT 1 [["id", 6]]
(34.0ms) SELECT COUNT(*) FROM "roles" INNER JOIN "users_roles" ON "roles"."id" = "users_roles"."role_id" WHERE "users_roles"."user_id" = $1 AND (((roles.name = 'admin') AND (roles.resource_type IS NULL) AND (roles.resource_id IS NULL))) [["user_id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
Participant Load (2.0ms) SELECT "participants".* FROM "participants" WHERE "participants"."video_id" = $1 [["video_id", 6]]
Rendered shared/_box.html.erb (14247.4ms)
Comment Load (1.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."node_id" = $1 [["node_id", 1]]
NodeComment Load (1.2ms) SELECT "node_comments".* FROM "node_comments" WHERE "node_comments"."node_id" = $1 [["node_id", 1]]
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
User Load (1.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 2]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 2]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]]
DEPRECATION WARNING: [Best_in_place] :type is deprecated in favor of :as . (called from best_in_place_deprecated_options at /Users/marcgayle/.rvm/gems/[email protected]/bundler/gems/best_in_place-0a0f62e19a8b/lib/best_in_place/helper.rb:152)
Rendered shared/_comments.html.erb (23.9ms)
Rendered dashboard/index.html.erb within layouts/application (14295.0ms)
Rendered shared/_nav.html.erb (0.4ms)
Rendered shared/_search.html.erb (0.5ms)
Rendered devise/registrations/_edit.html.erb (12.8ms)
Rendered shared/_edit_account_popup.html.erb (13.5ms)
(1.8ms) SELECT COUNT(*) FROM "activities" LEFT JOIN read_marks as read_marks ON read_marks.readable_type = 'PublicActivity::ORM::ActiveRecord::Activity'
AND read_marks.readable_id = activities.id
AND read_marks.user_id = 1
AND read_marks.timestamp >= activities.created_at WHERE "activities"."owner_id" = 1 AND (read_marks.id IS NULL)
Notification Load (2.4ms) SELECT "activities".* FROM "activities" LEFT JOIN read_marks as read_marks ON read_marks.readable_type = 'PublicActivity::ORM::ActiveRecord::Activity'
AND read_marks.readable_id = activities.id
AND read_marks.user_id = 1
AND read_marks.timestamp >= activities.created_at WHERE "activities"."owner_id" = 1 AND (read_marks.id IS NULL)
Rendered public_activity/node/_create.html.erb (0.1ms)
Rendered public_activity/node/_create.html.erb (0.1ms)
Rendered public_activity/node/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.2ms)
Rendered public_activity/node/_destroy.html.erb (0.2ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/node/_create.html.erb (0.1ms)
Rendered public_activity/node/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/participant/_create.html.erb (0.1ms)
Rendered public_activity/participant/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_destroy.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered public_activity/comment/_create.html.erb (0.1ms)
Rendered shared/_notifications.html.erb (127.8ms)
Rendered shared/_profile.html.erb (143.7ms)
Rendered devise/registrations/_edit.html.erb (15.2ms)
Rendered shared/_edit_account_popup.html.erb (16.0ms)
CACHE (0.0ms) SELECT "users".* FROM "users" INNER JOIN "memberships" ON "users"."id" = "memberships"."user_id" WHERE "memberships"."family_tree_id" = $1 ORDER BY "users"."first_name" ASC [["family_tree_id", 1]]
Rendered shared/_upload_video_popup.html.erb (7.2ms)
Rendered shared/_navbar.html.erb (173.1ms)
Rendered shared/_footer.html.erb (0.9ms)
Completed 200 OK in 14510ms (Views: 14448.1ms | ActiveRecord: 55.1ms)
我很想做的ActiveRecord的優化,使用預先加載而這一切爵士....但鑑於Views
時間之間的時間差那時候,那種做法似乎很愚蠢。
這是我Dashboard#Index
控制器:
def index
@family_tree = current_user.family_tree
@nodes = @family_tree.nodes.includes(:comments)
@video = Video.new
@videos = Video.all.where(:is_complete => true)
@node = current_user.nodes.new
@memberships = current_user.memberships.limit(3)
if params[:search]
@nodes = Node.node_search(params[:search])
else
@videos = Video.all.order('created_at DESC')
# flash[:notice] = "No results found"
end
end
這是我Dashboard/index.html.erb
:
<% if !resource.errors.messages.empty? %>
<!-- <div><%#= resource.errors.inspect %></div> -->
<div><%= devise_error_messages2! %></div>
<% end %>
<!-- Content -->
<div id="content">
<% if current_user.sign_in_count == 1 %>
<div class="hidden" id="new-user"></div>
<% end %>
<div class="container">
<div class="row">
<!-- Profile -->
<%= render "shared/profile_box" %>
<!-- // Profile -->
</div> <!-- //row -->
<!-- Video -->
<div id="video">
<!-- Box Add -->
<div class="box add-video" data-popup="add-video-step-1" data-step="3" data-intro="To upload a video simply click in this box or the upload a video button in the main bar.">
<a class="upload popupbox" href="#" data-popup="add-video-step-1">
<%= image_tag("buttons/upload-video.gif")%>
</a>
</div>
<!-- Box -->
<% @nodes.each do |node| %>
<!-- Upload Video Comment Popup -->
<%= render partial: "shared/upload", locals: {node: node} %>
<div class="box">
<%= render partial: "shared/box", locals: {node: node} %>
<%= render partial: "shared/comments", locals: {node: node} %>
</div>
<% end %> <!-- node -->
</div>
</div>
</div>
而不是混亂的問題與我的諧音碼,我想我會就讓它是,如果你們要求它,我會在稍後添加它們。
我懷疑有一件或兩件事情可以大幅減少視圖渲染時間。這是非常高的。
我也使用Turbolinks,但沒有緩存。
鑑於我使用Turbolinks,俄羅斯娃娃的緩存會在這裏推薦嗎?我的分析也是正確的,也就是說我比AR查詢更專注於視圖渲染。或者我應該繼續並優化這些嗎?
我不一定需要絕對100%的效率,我只是不想要14+秒的加載時間。這對我來說似乎很瘋狂。