Getting the Item Count of a large sharepoint list in fastest way

Posted by sooraj on Stack Overflow See other posts from Stack Overflow or by sooraj
Published on 2011-01-05T06:38:09Z Indexed on 2011/01/05 6:53 UTC
Read the original article Hit count: 173

Filed under:

I am trying to get the count of the items in a sharepoint document library programatically. The scale I am working with is 30-70000 items. We have usercontrol in a smartpart to display the count . Ours is a TEAM site.

This is the code to get the total count

SPList VoulnterrList = web.Lists[ListTitle];

SPQuery query = new SPQuery();

            query.ViewAttributes = "Scope=\"Recursive\"";
            string queries = "<Where><Eq><FieldRef Name='ApprovalStatus' /><Value Type='Choice'>Pending</Value></Eq></Where>";
            query.Query = queries;
            SPListItemCollection lstitemcollAssoID = VoulnterrList.GetItems(query);
            lblCount.Text = "Total Proofs: " + VoulnterrList.Items.Count.ToString() + " Pending Proofs: " + lstitemcollAssoID.Count.ToString();

The problem is this has serious performance issue it takes 75 to 80 sec to load the page. if we comment this page load will decrees to 4 sec. Any better approch for this problem

Ours is sharepoint 2007

© Stack Overflow or respective owner

Related posts about sharepoint2007