Nested QueryRepeater Question

Vic Carter asked on October 27, 2014 20:18

I am using a nested repeater to allow for a news feed to appear on my home page. The query allows for sites on the same kentico instance to pull from a singular news source. Recently I have noticed some performance issues that seem to be related to this configuration. Is there any optimization that I can do to alleviate some of the load on my system. Here is my transformation code:

<script runat="server">
    protected override void OnInit(EventArgs e)
    {
       base.OnInit(e);
        if ((this.Parent is IDataItemContainer) && (EvalInteger("SpotlightType") == 3))
        {
          IDataItemContainer cont = this.Parent as IDataItemContainer;
          if (cont != null)
          {
            rLatestNews.WhereCondition = "selectedBusiness.val = '" + Eval("SpotlightBusinessUnit") + "'";
            rLatestNews.TopN = EvalInteger("SpotlightNewsCount");
            rLatestNews.ReloadData(true);
          }else
          {
            Response.Write("Error: IDataItemContainer is null");
          }
        } 
        if ((this.Parent is IDataItemContainer) && (EvalInteger("SpotlightType") == 4))
        {
          IDataItemContainer cont = this.Parent as IDataItemContainer;
          if (cont != null)
          {
            rLatestNewsLocal.WhereCondition = "SiteName = '" + Eval("SiteName") + "'" ;
            rLatestNewsLocal.TopN = EvalInteger("SpotlightNewsCount");
            rLatestNewsLocal.ReloadData(true);
          }else
          {
            Response.Write("Error: IDataItemContainer is null");
          }
         }
    }

</script>


<%# ((DataItemIndex%3)==0)?"<tr>":"" %> 
<asp:Placeholder runat="server" visible='<%# IfCompare(EvalInteger("SpotlightType"),1, false, true) %>' >
    <td>
    <img src="<%# Eval("SpotlightImage") %>" alt="" <%# ((DataItemIndex%3)==0)?"width='252'":"width='288'" %>  height="108" />
    <h2><%# Eval("SpotlightTitle")%></h2>
    <p><%# Eval("SpotlightText")%></p>
    <asp:Placeholder runat="server" visible='<%# IfEmpty(Eval("SpotlightURL"),false, true) %>' >
    <a href="<%# Eval("SpotlightURL")%>" class="more"><%# IfEmpty(Eval("SpotlightURLText"),"Learn More", Eval("SpotlightURLText") ) %></a>
    </asp:Placeholder><br />
  </td>
</asp:Placeholder>  

<asp:Placeholder runat="server" visible='<%# IfCompare(EvalInteger("SpotlightType"),2, false, true) %>' >
  <td>
    <%# Eval("SpotlightCustomText")%>
    <asp:Placeholder runat="server" visible='<%# IfEmpty(Eval("SpotlightURL"),false, true) %>' >
    <a href="<%# Eval("SpotlightURL")%>" class="more"><%# IfEmpty(Eval("SpotlightURLText"),"Learn More", Eval("SpotlightURLText") ) %></a>
    </asp:Placeholder>
  </td>
</asp:Placeholder>

<asp:Placeholder runat="server" visible='<%# IfCompare(EvalInteger("SpotlightType"),3, false, true) %>' >
    <td rowspan="<%# IfCompare(EvalInteger("SpotlightNewsCount"),5,"1","3") %>">
  <h2><%# Eval("SpotlightTitle")%></h2>
    <cms:queryrepeater StopProcessing="false" runat="server" ID="rLatestNews" QueryName="custom.news.FilterByBusinessAndRegion" TransformationName="custom.news.newlatestexternal" OrderBy="NewsReleaseDate DESC" />
  <asp:Placeholder runat="server" visible='<%# IfEmpty(Eval("SpotlightURL"),false, true) %>' >
    <a href="<%# Eval("SpotlightURL")%>" class="more"><%# IfEmpty(Eval("SpotlightURLText"),"Learn More", Eval("SpotlightURLText") ) %></a>
    </asp:Placeholder>
  </td>
</asp:Placeholder>

<asp:Placeholder runat="server" visible='<%# IfCompare(EvalInteger("SpotlightType"),4, false, true) %>' >
    <td rowspan="<%# IfCompare(EvalInteger("SpotlightNewsCount"),5,"1","3") %>">
  <h2><%# Eval("SpotlightTitle")%></h2>
    <cms:queryrepeater StopProcessing="false" runat="server" ID="rLatestNewsLocal" QueryName="cpsbu.site_news.SiteNewsFeatured" TransformationName="cpsbu.site_news.NewsLatest" OrderBy="NewsReleaseDate DESC" />
  <asp:Placeholder runat="server" visible='<%# IfEmpty(Eval("SpotlightURL"),false, true) %>' >
    <a href="<%# Eval("SpotlightURL")%>" class="more"><%# IfEmpty(Eval("SpotlightURLText"),"Learn More", Eval("SpotlightURLText") ) %></a>
    </asp:Placeholder>
  </td>
</asp:Placeholder>

<%# ((DataItemIndex%3)==2) || (DataRowView.DataView.Count==(DataItemIndex+1))?"</tr>":"" %>

Previous versions did not allow for dynamic inclusion of the "news" spotlight(It was simply another repeater on the page, and do not appear to have the same issue. My goal was to make this as flexible as possible for the client. Is there anything I can do to make this more efficient. In general I do not make my transformations overly complicated, but it this case it was necessary. Also the nested repeater is never returning more than 5 results. Any assistance would be appreciated.

Recent Answers


Brenden Kehren answered on October 31, 2014 12:26

Vic,

Have you turned debugging on within the site to confirm your suspicions? Debugging will tell you how long sql queries take to run, how long macros take to process, etc. This might be beneficial to see exactly where the bottleneck is vs. taking a stab in the dark.

1 votesVote for this answer Mark as a Correct answer

Vic Carter answered on October 31, 2014 17:30

Turns out my query was returning way too many columns. Thank you for your response.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.