This is a migrated thread and some comments may be shown as answers.

Using filter on LINQ grid is slow

4 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 2
Michael asked on 21 Jun 2011, 05:53 PM
I'm stumped on this performance issue.  When paging a RadGrid I get instantaneous results.  However, when I filter any of the columns, the query takes around 10 seconds to complete and any paging applied after the filter remains just as slow.  If I remove the filter the performance is just fine.

Production is a SharePoint 2010 Server which is hosted in-house with a small number of users.  I am using a RadGrid control, version 2009.3..1314.35 that queries a table containing 30,000 records. I am using LINQ to SQL for the back-end.  I have used IE and Firefox in production.  On my development machine there are no performance issues. 

Below is my code.  Any help would be appreciated.

ASPX:
<telerik:RadGrid ID="rdgrdPeople" DataSourceID="people" PageSize="10" AllowPaging="true" AllowAutomaticDeletes="true" AllowMultiRowSelection="true" Skin="Windows7" OnItemDataBound="rdgrdPeople_ItemDataBound"
  AllowFilteringByColumn="True" AllowSorting="True" AutoGenerateColumns="false" runat="server">
    <GroupingSettings CaseSensitive="False" />
    <MasterTableView AutoGenerateColumns="false" DataKeyNames="Id" OverrideDataSourceControlSorting="true">
        <Columns>
            <telerik:GridHyperLinkColumn Text="View" UniqueName="View" AllowFiltering="false"  DataNavigateUrlFields="Id,Profile"
                            DataNavigateUrlFormatString="managecontact.aspx?id={0}&profile={1}" />
            <telerik:GridHyperLinkColumn Text="Edit" UniqueName="Edit" AllowFiltering="false"  DataNavigateUrlFields="Id,Profile"
                            DataNavigateUrlFormatString="managecontact.aspx?id={0}&profile={1}" />
            <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="Delete" CommandName="Delete" Text="Delete" ConfirmText="Are you sure you want to delete this person?" />
 
          <telerik:GridTemplateColumn AllowFiltering="false" SortExpression="Marked" HeaderText="Marked" UniqueName="Marked">
 
               <ItemTemplate>
                 <asp:CheckBox
                   ID="chkbxMarked" runat="server"
                   OnCheckedChanged="ToggleRowSelection"
                   Checked='<%# Eval("Marked") %>'
                   AutoPostBack="True" />
               </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="NamePrefix" SortExpression="NamePrefix" AllowFiltering="false" HeaderText="Name Prefix" />
            <telerik:GridBoundColumn DataField="LastName" SortExpression="LastName"  AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderText="Last Name" />
            <telerik:GridBoundColumn DataField="FirstName" SortExpression="FirstName" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderText="First Name" />
            <telerik:GridBoundColumn DataField="MiddleName" SortExpression="MiddleName" AllowFiltering="false" HeaderText="Middle Name" />
            <telerik:GridBoundColumn DataField="Phone1" SortExpression="Phone1" AllowFiltering="false" HeaderText="Phone" />
            <telerik:GridBoundColumn DataField="Phone1Ext" SortExpression="Phone1Ext" AllowFiltering="false" HeaderText="Ext." />
            <telerik:GridBoundColumn DataField="Email1" SortExpression="Email1" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderText="Email" />
            <telerik:GridBoundColumn DataField="Profile" SortExpression="Profile" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" HeaderText="Profile" />    
           
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
 
<asp:ObjectDataSource ID="people" runat="server" EnablePaging="true" SelectMethod="FindAllByProfile" DeleteMethod="Delete"
    TypeName="PRA.Business.PersonLogic" StartRowIndexParameterName="rowStart" MaximumRowsParameterName="numRows"
    SelectCountMethod="FindAllByProfileCount" >
    <SelectParameters>
        <asp:ControlParameter ControlID="drplstProfiles" PropertyName="SelectedItem.Value" Name="profileName" />
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="Id" />
    </DeleteParameters>
</asp:ObjectDataSource>

BLL:
public IList<Person> FindAllByProfile(string profileName, int rowStart, int numRows)
       {
           return profileName == "All" ? _repos.FindAll(rowStart, numRows) : _repos.FindAllByProfile(profileName, rowStart, numRows);
       }
 
       public int FindAllByProfileCount(string profileName)
       {
           return profileName == "All" ? _repos.FindAllCount() : _repos.FindAllByProfileCount(profileName);
       }

Repository:

public IList<Person> FindAll(int rowStart, int numRows)
      {
          using (PRADbDataContext db = new PRADbDataContext())
          {
              var data = from p in db.persons
                         join c in db.contacts on p.PersKey equals c.PersKey into personContacts
                         from pc in personContacts.DefaultIfEmpty()
                         orderby p.Modified descending
                         select new Person()
                                    {
                                        Id = p.PersKey,
                                        AddressId = p.AddrKey,
                                        DateModified = p.Modified,
                                        Email1 = p.EMail1,
                                        Marked = p.Marked,
                                        Phone1 = p.Phone1,
                                        Phone1Ext = p.PhExt1,
                                        NamePrefix = p.MrMs,
                                        FirstName = p.FName,
                                        LastName = p.LName,
                                        MiddleName = p.MName,
                                        Title = p.Title,
                                        Profile = pc.ProfKey ?? "N/A"
                                    };
              return data.Skip(rowStart).Take(numRows).ToList();
          }
      }
 
public int FindAllCount()
      {
          using (PRADbDataContext db = new PRADbDataContext())
              {
                  var data = from p in db.persons
                             join c in db.contacts on p.PersKey equals c.PersKey
                             select new Person()
                             {
                                 Id = p.PersKey,
                             };
                  return data.Count();
              }
      }


4 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 2
answered on 21 Jun 2011, 07:18 PM
I just wanted to update this thread.  I decided to take one of the problematic grids and place it in a standard ASP.NET Web Forms application.  I deployed it to the production server and it runs perfectly fine.

So it seems I have narrowed the issue down to SharePoint.  Are there any known issues or gotchas I should be aware of with my scenario?  
0
Tsvetoslav
Telerik team
answered on 23 Jun 2011, 09:08 AM
Hi Michael,

What kind of data are you querying? Is it a SPList?

Regards,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Michael
Top achievements
Rank 2
answered on 23 Jun 2011, 05:10 PM
The data is from a SQL Server 2008 database.  It's just a simple SharePoint Application Page using the Telerik RadGrid.  Nothing fancy going on.  The query isn't complex, the data I'm querying isn't ginormous. 

Funny thing is when I pull the RadGrid out of SharePoint and into a standard ASP.NET project the performance issues disappear. And I placed the test web site on the production server where SharePoint sits.  
0
Accepted
Tsvetoslav
Telerik team
answered on 24 Jun 2011, 08:51 AM
Hello Michael,

I'd recommend that you switch on Developer Dashboard for your SharePoint site and see where the bottleneck lies - however, it indeed should not have any relation to the RadGrid control. 

All the best,
Tsvetoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Michael
Top achievements
Rank 2
Answers by
Michael
Top achievements
Rank 2
Tsvetoslav
Telerik team
Share this question
or