kevinob
kevinob

Reputation: 677

Querying a 4000 rows list in SharePoint is slow as hell

I just want to fetch a list of items from the SiteUserInfoList list. This list holds roughly 4000 rows.

var watch = System.Diagnostics.Stopwatch.StartNew();

var qry = new SPQuery { Query = "<Where><Eq><FieldRef Name='ContentType'/><Value Type='Text'>MyValue</Value></Eq></Where>" };
var list = new List<Entity>();
using (var web = spSite.OpenWeb())
{
    var groups = web.SiteUserInfoList.GetItems(qry);
    foreach (SPListItem group in groups)
    {
       list.Add(new Entity
       {
          Id = group.ID,
          Guid = group.UniqueId,
          Title = group.Title
       });
    }
}

watch.Stop();
Console.Write(watch.ElapsedMilliseconds);

ElapsedMilliseconds gets an average of 20 seconds! How can that be so long?! (Server is a Xeon W-2145 that is shared for multiple VMs but still - CPU usage never goes beyond 20%)

I also tried:

Any idea? Please help optimizing :) Thank you.

Upvotes: 0

Views: 69

Answers (1)

kevinob
kevinob

Reputation: 677

Ok I found out that there is ContentTypesEnabled property that was set to false. Don't really know what is behind this property as it is not well documented. And I cannot set it back to false...

When I set it to true I'm now under 2 secs!

Upvotes: 1

Related Questions