List View Thresholds And Blocked Operations In SharePoint 2010

There have been several past posts that deal with the list threshold, such as here. A list may exceed the list view threshold and then some operations will be blocked. The big problem with this is that the default list view can’t be used to access the list, bad news bear! They have to be properly configured before they can work with a large list. The list view threshold blocks the database operations that affects more items than that threshold allows. It won’t just affect the number of items that have been returned.

There are two classifications that come into the picture when you have large lists: “List Exceeds The List Value Threshold” and “Container Exceeds The List View Threshold”.

There are operations that can be blocked when the size of the entire list exceeds the list view threshold. This occurs even if the items are placed into folders. These operations include managing and checking versions, operations of all items, and recursive queries. The views that return all items without folders can also be prevented. There are operations that affect a complete list too including adding a column or deleting indexes and they can be blocked.

There can be operations prevented due to the folder for the list containing more items than the list view threshold allows. You won’t be able to rename it or to delete it so you do need to be careful. The list view threshold can prevent you from performing some common actions when you setup your list. This is why you should configure the columns and indexes for a list before the size is greater than the list view threshold.

Should a list exceed what the list view threshold allows, then you need to plan to configure it correctly. You need to configure view and navigational options well in advance. However, lists can grow beyond the list view threshold and that will require some action from you. For example when you create a column or index that column in a list you need to be prepared for it to take time. The operations are prevented by the live view threshold. They can be performed during the daily time window. They can also be performed by the farm and computer administrators.

The operations need to be planned well in advance. The list may be too big so you will need to use a daily time window. An administrator with the right privileges may be needed in order to perform the necessary operations. It is possible for a list to become so large that some of the operations can time out when they are used in associated with a Web browser.

List Exceeds The List Value Threshold

  • Add/Remove/Update a list column All of the columns including lookup and calculated columns. There are updates such as name change. They aren’t blocked due to the fact that they won’t affect all of the items in the list.
  • Add/Remove/Update a list content type Every item in the list is affected so it is blocked if the list has more items than the list view threshold.
  • Create/Remove indexes it is blocked for any list that has more items than the list view threshold has it affects each item in the list.
  • Mange files The non indexed query fails for any list that has more items than the list view threshold.
  • Non indexed queries This includes filters and various sorts. The operation will fail if the list size is larger than the list view threshold. There isn’t an index so a full scan of the list occurs. The items will all be returned but the folders will be ignored.
  • Cross list query This includes the various queries by the Content Query Web Part. It follows the list view threshold setting for auditors and administration. The default for it is 20,000. For operations above that threshold it will fail.
  • Lookup columns This refers to those that enforce relationship behavior. You can’t offer lookup columns like this though if the list references content for more items than the list view threshold.
  • Delete a list This is blocked if the list has more items than the list view threshold due to the fact that it affects every item in the list.
  • Delete a site This affects all of the items in the list so it’s blocked for any list if there are more items in it than the list view threshold.
  • Save the list as a template This affects all of the items in the list so it is blocked for any list with more items than the list view threshold.
  • Show totals in list views This performs a query against all of the items in the list. It is blocked for a list that has more items than the list view threshold.
  • Enable/Disable attachments for a list This affects all of the items in the list so it will be blocked when the list offers more items than the list view threshold.
    Container Exceeds The List View Threshold

  • Delete/Rename/Copy a folder This fails if the folder contains more items than the list view threshold as too many of the rows will be affected.
  • Queries to filter non indexed columns This fails if the folder or list has more items than the list view threshold. It performs a full scan against the entire folder because there isn’t an index.
  • Fine grain security permissions This fails when the list or the folder that is being set has fine grained permissions that contain more items than the list view threshold as too many rows are affected. You can use the fine grain permissions on documents in a large list. However, you can’t set the permissions of the list or of the folders if they contain more than the list view threshold.
  • Open with Explorer This won’t show any items if a container has more items than the list view threshold, other than in reference to sub folders. If the root list contains more items than the list view threshold the “Open with Explorer” won’t show anything. In order to use Open with Explorer the list needs items to be organized into folders. The amount needs to be less than the list view threshold in the root for a given container.
Share

Existence of Folder and Files in SharePoint

From time to time in your SharePoint code, you are required to determine the existence of files and folders. This becomes important when developing WebParts / integrated SharePoint applications that will work with storage mediums in SharePoint such as SharePoint Document Libraries. Developing these types of conditional tests just means creating a Boolean test that will pass in a file name or a folder name that is a string which is used as a comparison operator. It is not real fancy, but can enhance your code in order to eliminate un-necessary loops and possibly reduce existence test execution bloat.

Firstly, you have to declare the Boolean file test, which is going to be static, taking in the folder and the filename as the parameters.

[csharp]
public static bool mySpFolderHasFile(SPFolder folder, string fileName)
[/csharp]

When declaring the Boolean folder test, you can do something similar in order to determine whether a folder contains a certain subfolder, however you are going to be passing the folder name in as a string as opposed to the filename.

[csharp]
public static bool myFolderHasFolder(SPFolder folder, string folderName)
[/csharp]

Once the test has been declared, the loop has to be declared in order to iterate through the relevant objects. The first loop is going to use a foreach declaration using the SPFile class. The SPFile class can be used in order to represent a file that exists within a document library, which is based against a certain SharePoint folder, SPFolder, which was passed as a parameter.

[csharp]
foreach (SPFile file in folder.Files)
[/csharp]

Similarly, you can determine the existence of a folder within a set of subfolders with a similar approach. The only difference between the two loops are that you are using SPFolder to instantiate the loop in the folder iteration, and SPFile to instantiate the loop in the previous sample.

[csharp]
foreach (SPFolder folder in folder.SubFolders)
[/csharp]

Lastly, you must declare the comparison operator in order to determine whether the file name exists or not. Otherwise, you will just be looping and not doing any type of operation to test for the certain set.

[csharp]
if (string.Compare(fileName, file.Name, true) == 0)
[/csharp]

Or, if you are testing whether a sub-folder exists, you can do a comparison against the folder name.

[csharp]
if (string.Compare(folderName, folder.Name, true) == 0)
[/csharp]

Small, and somewhat simplistic, piece of code, but very useful at times, I keep it in a shared library, as I recommend you should do to utilize throughout modules when you find it necessary. Once you have the loops done, you just have to set the code to return true; or return false; based on the conditions that you setup previously.

Share