Horrible Performance

Thread is closed for posting
2 posts, 0 answers
  1. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 23 Aug 2010 Link to this post

    Is this bad query syntax perhaps somewhere?....if I enable both of these I go from 1 second page load to 10 seconds.

    protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) {
        var filtered = (from r in this.Requests
                        select new {
                            ApprovalID = r.SittingWithApprovalID,
                            SittingWithApprovalID = r.SittingWithApprovalID,                   
                            SittingWithApprovalChainLevel = r.SittingWithApprovalChainLevel,
                            CreateDate = r.SittingWithApproverCreatedDate,
                            StatusText = r.Status,
                            ResidentEmail = r.ResidentEmail
        debugLabel.Text = this.Email;
        ((RadGrid)source).DataSource = filtered.Distinct().OrderByDescending(x => x.CreateDate);

        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) {
            if (e.Item is GridDataItem) {
                try {
                    GridDataItem item = e.Item as GridDataItem;
                    if (Request.QueryString["GUID"] != null) {
                        if (item["SittingWithApprovalID"].Text.ToString() == Request.QueryString["GUID"].ToString())
                            ((GridDataItem)e.Item).Display = false;
                        Guid approvalid = new Guid(item["SittingWithApprovalID"].Text);
                        //RTODataLayer.Approval approval = RTOHelper.RTOScope.Extent<RTODataLayer.Approval>().FirstOrDefault(x => x.ApprovalID == approvalid);
                        List<ViewAllRequest> dates = (from d in this.Requests
                                                      where d.Active != 'N' && d.SittingWithApprovalID == approvalid
                                                      select d).ToList();
                        int totalCount = dates.Count;
                        int expiredCount = 0;
                        foreach (RTODataLayer.ViewAllRequest date in dates) {
                            if (DateTime.Now > date.FromDate)
                        item["NoticeColumn"].Text = totalCount + " dates";
                        if (expiredCount > 0)
                            item["NoticeColumn"].Text += "<br /><span style='color:#c00300'>" + expiredCount + " are expired</span>";
                    } else {
                        if (item["SittingWithApprovalID"].Text.ToString() == this.AlreadyViewingThisApprovalID)
                            ((GridDataItem)e.Item).Display = false;
                }catch(Exception ex){

    private List<ViewAllRequest> _requests = null;
    public List<ViewAllRequest> Requests{
            if (_requests == null) {
                RTODataLayer.Approver approver = null;
                if (Membership.GetUser() != null)
                    approver = RTOHelper.RTOScope.Extent<RTODataLayer.Approver>().FirstOrDefault(x => x.MedportalUID == new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                if (approver != null) {
                    _requests = (from r in RTOHelper.RTOScope.Extent<RTODataLayer.ViewAllRequest>()
                                where (r.SittingWith.Contains(this.Email) || r.SittingWith.Contains(approver.ApproverName))
                                      && r.Status.Contains("Pending")
                                select r).ToList();
                } else {
                    _requests = (from r in RTOHelper.RTOScope.Extent<RTODataLayer.ViewAllRequest>()
                                where (r.SittingWith.Contains(this.Email))
                                      && r.Status.Contains("Pending")
                                select r).ToList();
            return _requests;
  2. Serge
    Serge avatar
    375 posts

    Posted 24 Aug 2010 Link to this post

    Hi Steve,

     From what I can see the only place where OpenAccess is called is in the Requests property. Also ToList is called which means that the query is executed immediately. I suggest tracking how much time is needed for the retrieval of this query's result. Can you please track the time using the stopwatch class? Just wrap the property getter with the stopwatch.Start() and stopwatch.Stop() calls and set a breakpoint after the stop. If this query is executed in a timely fashion the issue possibly lies in the ItemBound event. However both event actually will be working only with in-memory results which is usually pretty fast.

    Please note that the ItemBound event is called for each item in the datagrid, so you might consider some kind of batching this operation. 

    I am looking forward to your response and to resolving this issue.

    Sincerely yours,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top