Sharepoint Example Large Lists Unique Columns

Sharepoint Tutorials about Large List and Unique Columns

This Sharepoint 2013 or 2010 example is about how we can work with  how you can work with large lists and what unique columns look like. SharePoint 2013 has support for very large lists of up to 50 million items. With this expanded list size comes the ability to throttle and control how much data is returned to the user and prevent large queries from compromising the SharePoint farm. 
  • For this demo we have created a console application named FillUpLargeListOpen a command window and navigate to it. 
  • Execute the console application by specifying the URL to your SharePoint site and the name of the list you want to populate with 6000 items.
  • we need to create a console application that creates a large list with 6000 items in it. 
  • The List Settings page will warn you that the threshold of 5000 items is exceeded.
  • When the list has a large number of items but hasn’t reached the threshold yet, the bar will warn you that the list is not throttled yet but that the list has passed the warning level.
  • Open an Internet browser and navigate to the LargeList in your SharePoint site.
  • Navigate to the List Settings page and notice the extra section under the list description telling that the list contains 6000 items while the threshold is 5000 items


The demo console application will query a large list with a number of items that exceeds the threshold. This will work when you are logged in as the administrator.
You can disable the throttling on a list by setting the EnableThrottling property to false. 
Open the ListThrottling project from the starter files in Visual Studio 2010.
This console application will query the LargeList list.
The largeList.Items method will throw an error when logged in as a regular user but will be executed when logged in as administrator.


static void Main(string[] args)
{
    SPListItemCollection items;

    // get reference to site passed in as an argument
    using (SPSite siteCollection = new SPSite(
   "http://intranet.contoso.com/sites/ListsAndSchemas"))
    {
       SPList largeList = 
          siteCollection.RootWeb.Lists["LargeList"];

       // if logged in as a regular user, the following 
       // would throw an exception 
       // if the list contained more than 5000 items...
       items = largeList.Items;
       Console.WriteLine(items.Count);

       // the following will disable the throttling on 
       // the list
       largeList.EnableThrottling = false;
       largeList.Update();
       items = largeList.Items;
       Console.WriteLine(items.Count);
   }
}
If you want to check whether a list is throttled before executing a query, you can test upon the IsThrottled property of the list.You can add the following code to check whether the list is throttled or not.


It is not a good idea to test on the number of items in the list because you don’t know what the throttling setting is in the web application.You can also decide to put the throttle off.Set the EnableThrottling property of a SPList object off to disable throttling:


This code can run under a normal user account.Open the Windows PowerShell V2 (CTP3) command shell.Execute the SharePoint snap-in to load the SharePoint assemblies:Add-psSnapin Microsoft.SharePoint.Powershell.Define a variable for the site collection using the PowerShell cmdlet get-SPSite:

$sitecol = get-SPSite http://intranet.contoso.com

The settings about throttling are not set at site collection level but at web application level. The WebApplication property will return the web application. To get all properties of the WebApplication, you can run the following command:
$sitecol.WebApplication | select *

The property MaxItemsPerThrottledOperation returns the upper limit:
$sitecol.WebApplication.MaxItemsPerThrottledOperation

You can also check the property MaxItemsPerThrottledOperationOverride how far you can override this limit. In this case super users are able to execute queries up to 20000 items:
You can also check if it is allowed to override the throttling settings:
To check the properties of a specific list, you can execute the following PowerShell command:
$sitecol.RootWeb.Lists[“LargeList”]
The property concerning throttling is the IsThrottled property, indicating whether the list is throttled or not.

0 comments:

Post a Comment