I was IMing with unsung heroine Lori Gowin today. We were kvetching about how list throttling in SharePoint 2010 is not quite as consistent as we wished it was. She was doing some work for a customer and needed to explain the behavior and take steps to adjust it, if necessary. She was asking if I had any scripts in my bag of tricks to help. Of course I did. I decided to share them with the rest of the class.
First, here’s a script that creates a list using the “Custom" List” template, and adds a column of the type “number” called “Number.” (I know, very creative)
$web = get-spweb http://portal.contoso.com
$web.Lists.Add("LargeList","Big List",$web.ListTemplates["Custom List"])
$list = $web.Lists["LargeList"]
You can add any columns you’d like, or not add my Number column. Now that the list has been created, let’s add a few thousand items to it. Out of the box, SharePoint doesn’t start throttling lists until there are 5000 items, so you’ll want to create at least that many. This script creates the list items:
for ($i=1; $i -le 5001; $i++)
$item = $list.items.add()
$item["Title"] = "Todd is cool " + $i
$item["Number"] = "$i"
That will create 5001 items in the list. For whatever reason that script doesn’t seem to work if the text in the Title is not “Todd is cool.” I don’t understand it either. When I ran that on my VM it only took a couple of minutes to run, so it shouldn’t kill your environment.
After the list has more than 5000 items you can experience throttling for yourself. If you’re an administrator SharePoint assumes you know better, and it won’t throttle you until there are 20000 items in the view. That and the 5000 item threshold are set per web application and can be modified in Central Admin or with PowerShell. The user throttling (5000 items) property is MaxItemsPerThrottledOperation while the admin property is MaxItemsPerThrottledOperationOverride and it’s set to 20000 items by default.
Hope that helps, and happy throttling,