如何追踪缓慢的对我的方案的来源? [英] How can I track the source of slowness for my scenario?

查看:161
本文介绍了如何追踪缓慢的对我的方案的来源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我难倒这个性能问题。当寻呼radgrid控件我得到即时的结果。然而,当我过滤任何列的查询需要10秒左右才能完成,过滤之后的任何页面仍然只是缓慢。如果我删除过滤器的性能就好了。

生产是一个SharePoint 2010服务器是在内部举办了少量的用户。我使用的是radgrid控件控制,版本2009.3..1314.35,查询含30000条记录的表。我使用LINQ到SQL为后端。我已经在生产中使用IE和Firefox。在我的机器有没有性能问题。

查询并不复杂,记录源不是特别大,交通低,所以我不知道如何跟踪这个问题了。这里有一些想法我有:


  • 的东西不对我的LINQ查询。

  • 误用或radgrid控件的误解。

  • 数据库未优化?我从Access到SQL Server 2008将它转换。

  • 网络问题?

下面是我的code。任何帮助将是AP preciated。

ASPX:


    
    
        
            
            
            

 < Telerik的:GridTemplateColumn AllowFiltering =false的SORTEX pression =标注的HeaderText =标记UniqueName =标记>           <&ItemTemplate中GT;
             < ASP:复选框
               ID =chkbxMarked=服务器
               OnCheckedChanged =ToggleR​​owSelection
               选中='<%#的eval(标记)%>'
               的AutoPostBack =真/>
           < / ItemTemplate中>
        < / Telerik的:GridTemplateColumn>
        < Telerik的:GridBoundColumn数据字段=名称preFIXSORTEX pression =名称preFIXAllowFiltering =假的HeaderText =名称preFIX/>
        < Telerik的:GridBoundColumn数据字段=姓氏SORTEX pression =姓氏AutoPostBackOnFilter =真CurrentFilterFunction =包含的HeaderText =姓/>
        < Telerik的:GridBoundColumn数据字段=姓SORTEX pression =姓AutoPostBackOnFilter =真CurrentFilterFunction =包含的HeaderText =名/>
        < Telerik的:GridBoundColumn数据字段=中间名SORTEX pression =中间名AllowFiltering =假的HeaderText =中间名/>
        < Telerik的:GridBoundColumn数据字段=电话1SORTEX pression =电话1AllowFiltering =假的HeaderText =电话/>
        < Telerik的:GridBoundColumn数据字段=Phone1ExtSORTEX pression =Phone1ExtAllowFiltering =假的HeaderText =外部。 />
        < Telerik的:GridBoundColumn数据字段=EMAIL1SORTEX pression =EMAIL1AutoPostBackOnFilter =真CurrentFilterFunction =包含的HeaderText =电子邮件/>
        < Telerik的:GridBoundColumn数据字段=简介SORTEX pression =个人资料AutoPostBackOnFilter =真CurrentFilterFunction =包含的HeaderText =档案/>    < /专栏>
< / MasterTableView>


    
        
    
    
        
    

BLL:

 公开的IList<&人GT; FindAllByProfile(字符串PROFILENAME,诠释rowStart,诠释其行)
   {
       返回PROFILENAME ==所有? _repos.FindAll(rowStart,其行):_repos.FindAllByProfile(PROFILENAME,rowStart,其行);
   }   公众诠释FindAllByProfileCount(字符串PROFILENAME)
   {
       返回PROFILENAME ==所有? _repos.FindAllCount():_repos.FindAllByProfileCount(PROFILENAME);
   }

存储库:

 公开的IList<&人GT;的FindAll(INT rowStart,诠释其行)
  {
      使用(PRADbDataContext DB =新PRADbDataContext())
      {
          从db.persons p VAR数据=
                     将C在p.PersKey db.contacts等于c.PersKey到personContacts
                     从PC中personContacts.DefaultIfEmpty()
                     排序依据p.Modified降
                     选择新的Person()
                                {
                                    ID = p.PersKey,
                                    AddressId = p.AddrKey,
                                    DateModified = p.Modified,
                                    EMAIL1 = p.EMail1,
                                    标志着= p.Marked,
                                    电话1 = p.Phone1,
                                    Phone1Ext = p.PhExt1,
                                    名称preFIX = p.MrMs,
                                    名字= p.FName,
                                    姓氏= p.LName,
                                    中间名= p.MName,
                                    标题= p.Title,
                                    简介= pc.ProfKey? N / A
                                };
          返回data.Skip(rowStart)。取(其行).ToList();
      }
  }  公众诠释FindAllCount()
  {
      使用(PRADbDataContext DB =新PRADbDataContext())
          {
              从db.persons p VAR数据=
                         将C在db.contacts上p.PersKey等于c.PersKey
                         选择新的Person()
                         {
                             ID = p.PersKey,
                         };
              返回data.Count();
          }
  }


解决方案

我推荐使用LINQPad来模拟查询。


  1. 您可以查看SQL选项卡,看到正在生产的所有SQL。如果它是SQL本身引起的问题,你可以分析它在SQL Server Management Studio中,看看它为什么要花这么长时间。

  2. 您可以加载您的DLL和运行的实际方法,看看这件事情​​做的方法处理数据的方式。

  3. 如果你可以告诉你的方法没有任何问题上运行,那么你可以将问题缩小到Telerik控制在呼唤你的方法的方式。

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.

The query isn't complex, the record source isn't exceptionally large and the traffic is low, so I'm not sure how to track the issue down. Here are some thoughts I have:

  • Something is wrong with my LINQ query.
  • Misuse or misunderstanding of the RadGrid.
  • Database isn't optimized? I converted it from Access to SQL Server 2008.
  • Network issue?

Below is my code. Any help would be appreciated.

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);
   }

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();
          }
  }

解决方案

I'd recommend using LINQPad to emulate the queries.

  1. You can look at the SQL tab to see all the SQL being produced. If it's the SQL itself causing the problem, you can profile it in SQL Server Management Studio and see why it's taking so long.
  2. You can load your DLL and run your actual methods, to see if it's something to do with the way the method is handling the data.
  3. If you can tell that your method runs without a problem, then you can narrow down the issue to the way the telerik controls are calling your methods.

这篇关于如何追踪缓慢的对我的方案的来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆