Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to know the fastest way to access a list. Would it be:

            SPWeb web = site.RootWeb;
            SPList activityListFromUrl = web.GetList("/Lists/ActivityList");

or:

            SPWeb web = site.RootWeb;
            SPList activityListFromGuid = web.Lists[new Guid("aaa-aaa-aaa-aaa")];

or perhaps some other way?

share|improve this question
1  
Duplicate of sharepoint.stackexchange.com/questions/32898/… –  Andy Burns Mar 29 '12 at 17:13
1  
Its not a duplicate, I posted both those questions and I believe they are asking different things. This is regarding speed, the other is regarding general benefits of using a Guid vs a Title or URL. –  Meyer Denney Mar 29 '12 at 17:50

2 Answers 2

up vote 8 down vote accepted

web.Lists[guid] is the fastest.

web.GetList(url) calls a couple of methods to get the guid and then returns web.Lists[guid]

share|improve this answer
    
web.Lists[guid] - is not fastest. For some reason, TryGetList is faster! –  Aviw Apr 29 at 5:30

The only way to definitively answer "faster" type questions is to test in your environment.

Your farm (hardware, network, etc.) is going to be different than everybody else. So any advice you get will not apply to your configuration.

share|improve this answer
    
Does web.Lists[guid] load all the site lists into memory before accessing it like web.Lists.TryGetList() does? –  Meyer Denney Mar 29 '12 at 16:11
    
No matter the answer to the question, performance can only be measured by doing actual measurements. (And the answer could be determined by reflecting those methods.) –  Paul Schaeflein Mar 29 '12 at 19:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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