Results are unacceptable in production. Best performance is 49s to render 89 items on an otherwise unloaded machine.
Looking at Mini Profiler (first few lines only):
SAMSUNG on Fri, 22 Apr 2016 22:48:08 GMT
duration (ms) from start (ms) query time (ms)
http://localhost:30321/OrchardLocal/notables-... 96.2 +0.0 4 sql 18.2
Controller: Contents.ItemController.Display 655.7 +48.1 ! 11 sql 255.1
Result: System.Web.Mvc.ViewResult 363.2 +704.6 ! 36 sql 97.0
Shape Display: Shortlist (Detail) (Projection... 38752.1 +1066.7 ! 751 sql 705.9
Shape Display: Content (Summary) (Book) 830.4 +1343.2 ! 1 sql 0.7
Shape Display: Content (Summary) (Book) 79.4 +2608.5 ! 1 sql 2.2
Shape Display: Content (Summary) (Book) 45.9 +3025.2 ! 1 sql 0.7
The line that worries me is obviously the 751 repetitions within the Shortlist shape display and the duration of 38 seconds.
The Book display times hover around 80ms each, for a total of 80 * 89 = 7 seconds. Not great, but still...
The problem is how shortlist.cshtml works:
var cm = WorkContext.Resolve<IContentManager>();
@foreach (var contentItem in Model.ContentItems)
var shape = cm.BuildDisplay(contentItem, "Summary");
shape.Style = "Shortlist";
<div class="col-lg-4 col-sm-6" >
Calling BuildDisplay on each item in the projection results is not the best way to go about rendering each book (content item). I also, now suspect it's not a question of data design but the way I have written this shape.
Can anyone suggest a better way to go?
As far as I can tell, the only list provided to a Shape by a Projection is on Model.ContentItems, which means I need to convert each ContentItem to a shape to render it, or of course I can just render it in place. But since I already have a Book summary shape,
I would prefer to use that.
OK I have now rewritten Shortlist to render the items inplace, without and further calls to Display. Render time has gone down from 49s to 6s. Still not fantastic, but much better. The original question still stands: Would I get any better performance from
hard-coding the Book ContentType?