Does anyone know how the performance of searching for items compares to using the object model to access them?
When I say "object model" i mean using SPList to get a collection of SPListItems and iterating through. Example:
foreach (SPListItem li in w.Lists[ListName].Items.Cast<SPListItem>().Where(t => Convert.ToDateTime(t["pubenddate"]) >= DateTime.Now))
{
items.Add(li);
}
If I were using search to do this, I would define a search scope that only includes items where pubenddate >= Today's Date
, select all items and do my foreach
on that.
So i'm wondering:
- Does the number of items in the target list affect which of these will perform faster?
- Is one of these methods always faster than the other?
- Is one of these generally considered "best practice"?
- Is one of these methods better if I am looking through multiple lists?