我对此性能问题感到困惑。在分页RadGrid时,我得到了瞬时结果。但是,当我过滤任何列时,查询大约需要10秒才能完成,并且在过滤器之后应用的任何分页都会保持同样缓慢。如果我删除过滤器,性能就好了。
生产是SharePoint 2010服务器,由少数用户在内部托管。我正在使用RadGrid控件,版本2009.3..1314.35,查询包含30,000条记录的表。我正在使用LINQ to SQL作为后端。我在生产中使用过IE和Firefox。在我的开发机器上没有性能问题。
查询并不复杂,记录来源不是特别大且流量很低,所以我不确定如何跟踪问题。以下是我的一些想法:
以下是我的代码。任何帮助将不胜感激。
ASPX:
<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>
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);
}
存储库:
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();
}
}
答案 0 :(得分:2)
我建议使用LINQPad来模拟查询。