此控制檯輸出看起來是否正常?導軌慢速視圖呈現
16:10:01 rails.1 |開始GET「/」爲10.0.2.2於2015-11-01 16:10:01 +0000 16:10:02 rails.1 |通過PagesController#home處理HTML 16:10:02 rails.1 | (1.5ms)SELECT COUNT()FROM「parks」16:10:02 rails.1 | (1.0ms)SELECT COUNT()FROM「trains」WHERE「trains」。「superseded_at」IS NULL 16:10:02 rails.1 |列車載荷(10.9ms)選擇「列車」*從「列車」排列列車「列車」。「列車排列」ASC 16:10:02 rail.1 |循環加載(26.6ms)選擇「循環」。*從「循環」中選擇「循環」。「train_id」 IN(22147,21958,22055,22059,22356,22045,22001,22072,21836,22000,21800,22042,22373,21818,22024,22364,22365,22168,21863,22242,22054,22060,21899 ,22392,22117,21920,21822,22354,22401,21931,21826,21834,22306,21970,21980,21791,21790,21961,22037,21955,21985,22191,22391,21870,22004,22180,22164,22383 ,22405,22161,22169,22254,21812,22031,22219,22063,21873,22028,22232,21942,22175,21953,21787,22251,21900,22206,21805,21793,22390,22066,21783,22376,22083 ,22415,22346,21913,21932,22011,22394,22250,21866,22328,22324,21839,21939,22021,22087,22290,22027,21993,22065,22187,22278,21902,21861,21963,21952,22304 ,22293,22284,22279,22269,21848,21788,21855,21854,22209,21857,21784,22188,22178,22181,22166,22146,21883,22239,22137,22135,21903,22133,22127,22099,22098 ,22095,22090,21912,22096,22398,22397,22222,21937,21936,22006,21998,22361,22380,22023,21979,21810,22351,22204 ,22357,22396,22240,22198,22208,22211,21926,22139,22294,22297,22026,22344,21959,22082,22094,22067,21974,22106,22126,22277,21809,22141,22384,22234,22404 ,22243,22049,21881,22409,22159,21829,21846,21885,21878,21890,21897,21910,21919,22221,22228,21934,21935,21977,21994,22044,22051,22046,22047,22062,22084 ,22103,22109,22123,22116,22121,22124,22237,22241,22142,22184,22189,22196,21789,22255,22256,22314,22368,22371,22411,21992,22104,22100,22056,22322,22020 ,22165,22203,22010,22227,22149,22015,22353,22275,21880,22274,22032,22064,21989,22310,22330,22245,21823,22183,22374,21884,21908,22119,22105,22025,22319 ,21838,22002,22048,21850,21865,22085,22143,22285,21924,22102,22323,22073,21909,21786,22318,22151,22077,21799,22113,22316,21803,22308,22289,21840,22271 ,22366,22185,21951,21871,21945,21802,22199,22336,22007,21796,22343,22387,21916,22305,22195,22338,22226,2219 2,22249,22217,22130,22120,22296,22307,21990,22043,21987,21907,22138,21815,22112,22231,21949,21978,21950,21969,22375,22367,22362,21940,21933,21930, 21929,22332,22016,22327,22019,22298,22038,21923,22268,21804,22229,22267,22259,22253,21851,21853,22194,22068,21869,22190,22160,22079,22148,22402,22236, 22097,21915,22101,22128,22129,22400,22111,21828,21896,22281,21794,22320,21797,22326,21806,21981,21964,22378,22370,22013,22291,22295,22093,22122,21795, 22108,22272,21921,22340,22012,22399,22110,22299,22286,22041,22218,21798,22177,22089,21967,21886,22282,21960,22359,22358,21821,22395,21971,22207,21973, 21876,22408,22174,22125,21898,22091,22238,22403,22248,21887,22144,22081,22076,21891,22170,22173,21874,22176,22182,21867,22406,22197,22200,22205,21986, 22058,21847,21792,22057,21845,22263,22407,22260,22270,22266,22393,21844,22280,22030,22309,21982,22018,22342,218 24,21946,21827,21819,21999,22413,22369,22414,21817,21814,22381,22389,22382,21997,21954,22115,21905,21860,21901,22311,22193,22230,22313,21991,21816, 22363,22114,21938,22186,22179,21928,21983,22360,22022,22092,21864,21831,22074,22257,22003,22131,22388,21894,22349,22337,22348,21996,22140,21825,22347, 21966,22132,22345,22352,22152,22202,22210,22075,22088,22172,22134,22118,22086,22171,21922,22107,21917,21868,21879,22158,22386,22157,21841,21957,22163, 21842,21843,22155,22220,22287,22040,22069,22201,22071,22061,22078,21895,22053,21914,22212,22080,22300,22412,22213,22301,22154,22153,21832,21801,22145, 21906,21911,21995,22224,21904,21856,21852,22252,22385,22264,22052,21984,22235,21811,22246,21956,21892,22288,22039,21888,21837,22292,22036,22035,21968, 22303,22034,21925,21941,22312,21927,22321,22317,21962,22325,22331,22329,22339,21813,21877,21875,21976,22410,22 225,22247,22215,22335,21965,22341,22233,22334,22005,22333,22315,21988,22029,21835,21858,22276,22050,21862,21882,22273,22262,22261,22265,21872,21785, 22009,21947,21893,22214,21944,21820,22008,22216,22302,22033,22223,21972,22156,21849,22377,22162,22070,21948,22167,22136,22355,22350,22379,21830,21975, 22372,21943,22258,22017,21918,21859,21808,21889,21807,22283,22150,22244,22014,21833)16時10分02秒rails.1 | (0.6ms)SELECT COUNT(*)FROM「photos」16:10:03 rails.1 |在佈局/應用程序中渲染頁面/ home.html.erb(0.4ms)16:10:03 rails.1 |渲染共享/ _svg.html.erb(0.6ms)16:10:03 rails.1 |渲染共享/ _svg.html.erb(0.1ms)16:10:04 rails.1 |渲染共享/ _banner_slideshow.html.erb(0.1ms)16:10:04 rails.1 |渲染共享/ _flash_messages.html.erb(0.4ms)16:10:04 rails.1 |渲染共享/ _svg.html.erb(0.1ms)16:10:04 rails.1 |渲染共享/ _svg.html.erb(0.1ms)16:10:04 rails.1 |呈現共享/ _svg.html。erb(0.1ms)16:10:04 rails.1 |渲染共享/ _svg.html.erb(0.1ms)16:10:04 rails.1 |渲染共享/ _svg.html.erb(0.1ms)16:10:04 rails.1 |在2414ms內完成200 OK(查看:2033.0ms | ActiveRecord:40.6ms)
爲什麼渲染的各個部分佔用小於1ms但總視圖渲染時間超過2秒?
home.html.erb: - 我將它清空,看看這裏有沒有什麼東西阻礙了緩慢,但即使輸出一個單詞,總視圖渲染時間也超過了2秒。
blah
_svg.html.erb:
<svg role="img" aria-labelledby="title desc" class="<%= classs if local_assigns[:classs] %>">
<% if local_assigns[:title] %>
<title id="title"><%= title %></title>
<% end %>
<% if local_assigns[:description] %>
<desc id="desc"><%= description %></desc>
<% end %>
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#<%= hash %>"></use>
</svg>
_banner-slideshow.html.erb:
<div class="gallery banner banner--slideshow">
<div class="gallery__slide"></div>
<div class="gallery__slide"></div>
<div class="gallery__slide"></div>
<div class="gallery__slide"></div>
</div>
_flash-messages.html.erb:
<% if flash.any? %>
<% flash.each do |type, message| %>
<%= render partial: 'shared/flash_message', locals: { type: type, message: message } %>
<% end %>
<% end %>
_flash-message.html.erb:
<div class="message-box message-box--<%= type %>">
<a class="close" data-dismiss="alert">×</a>
<%= message %>
</div>
你能粘貼意見嗎?也許問題是視圖內的N + 1查詢 – matanco
@matanco添加視圖到OP – rctneil