Thursday, September 5, 2013

Web.Lists, GetLists, and TryGetLists Performance

  • Getting a list or library from a spweb with a large number of lists and libraries. In my test case each spweb had about 90,000 document libraries on sp2010 sp1.
  • You cannot cache the spweb.Lists object across calls. 
    • Ex:  Dynamically looking up a library for each document uploaded via a custom web service or event receiver.
  • Each call to spWeb.Lists.TryGetList(libName) took 13 seconds to process since any access to the Lists collection returns the metadata for all lists in the spweb.
  • Had to recode the solution to access the libraries using the URL rather than the list name, resulting in sub-second processing. spWeb.GetList(listURL)


  1. Hello!

    How long does it take to get list using "SPWeb.GetList(Url)"?

    1. In my environments (10000 lists) I have following situation:
      Test 01: Lists 10003 TryGetList List found 00:00:00.0020201
      Test 02: Lists 10003 TryGetList Not exist 00:00:00.0072657
      Test 03: Lists 10003 GetList(Url) List found 00:00:00.0130943
      Test 04: Lists 10003 GetList(Url) Exception 00:00:00.0036437
      Test 05: Lists 10003 Lists[ID] List found 00:00:00.0034549
      Test 06: Lists 10003 Lists[ID] Exception 00:00:00.0025844

      So, GetList(Url) - is very long. TryGetList is much faster.

    2. Also, please note that this was based on re-instantiating the spweb every call (simulating a single find). Trygetlist would always run faster if the lists collection is cached.