Reputation: 677
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:
fetching the entire list and filtering it in the code. It is a little bit faster (15 sec)
ContentType Indexed property is false (computed value based on ContentTypeId), but ContentTypeId is true. (So I assume ContentType is indexed somehow?)
fetching the results with RowLimit. Got the best results with RowLimit = 5000 (?!). (tried 100, 1000, 2000, ...8000): 6 sec, still too long!
Any idea? Please help optimizing :) Thank you.
Upvotes: 0
Views: 69
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