0

I have list with 60000 items .With the below code ,how much time is required for code to execute ? I am aware of developer dashboard . But what should be the correct time to execute 60000 items with best practices?

using (SPSite spSite = new SPSite(SiteUrl))
{
using (SPWeb web = spSite.OpenWeb())
{
    SPList listUsers = web.Lists[User_List];
    //CAML query to find a user and retrieve 2fields out of 16 fields.
    items = listUsers.GetItems(query);
    if (items.Count > 0)
{
   if (items[0][Status] != null)
{
   Status = items[0][Status].ToString();
}
}

3 Answers 3

1

There is no 'correct' time.

The execution time will vary depending on your environment specs etc.

That code looks pretty good at a helicopter level.

Things that might help improve performance there are all related to the query that you compose.

First of all make sure that all the filtering columns in the query are indexed, this will help a lot. The next is to make sure that you're avoiding recursive queries, those queries that go inside all your folders are killers! Finally think about order of operations, if you have two filters then order the query such that the most specific filter is the first applied. i.e. if you have two filters, one which matches ~10% of your list and one that matches ~1% of the list make sure the 1% filter fires first.

2
  • Yes i understand . But if my query takes 500ms to load for 60000 data . Is this good or should i work on it to make it 100ms ?
    – Nikhil J
    Commented Apr 25, 2014 at 16:05
  • 1
    I guess 500ms is fine for 60000 items and your query is most likely optimized. SharePoint is not the fastest environment after all. Commented May 1, 2014 at 4:22
1

It depends on your Setup. but I suggest you to use web.Lists.TryGetList[User_List] instead of web.Lists[User_List] . web.Lists[User_List] throws a null reference error if the list is not there

1

Even though question is about improving the performance of the query and that has been answered by @GavinB, I want to point out that if you know the url of the list then a better way to get the list is SPWeb.GetList instead of SPWeb.Lists in terms of performance.

SPWeb.Lists("name")
using (SPSite site = new SPSite(strSite))
{
    using (SPWeb web = site.OpenWeb())
    {
        SPList oList = web.Lists ["MyList"]
    }
}

In this case, it loads the metadata* of the all lists in that specific SPWeb object. Then it does SPList.Title comparison with metadata of all the lists returned and then it returns the matching list from the SPWeb.Lists collection.

SPWeb.GetList (string strUrl)
using (SPSite site = new SPSite(strSite))
{
   using (SPWeb web = site.OpenWeb())
    {
      SPList oList = web.GetList("http://Site/list/AllItem.aspx")
    }
}

In this case, first retrieves the list GUID from the url (database hit), then it loads the metadata* for that specific list.

Reference: http://blogs.msdn.com/b/sowmyancs/archive/2008/10/26/best-practices-sharepoint-object-model-for-performance-tuning.aspx

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.