SharePoint 2010 List Throttling

By Jatin Prajapati

In this FAQ we will see how to interact with List throttling programmatically.

List throttling providing in SharePoint 2010 allows us to trim out the result set regardless of the number of results requested to stop the problems like locking of the database in multiuser environment or performance decrease.

Following code example give you the overview of how to interact with List throttling using C# and Object Model in SharePoint 2010.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;

namespace SP2010Example
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                SP2010ListThrottlingProgramming sp2010List = new SP2010ListThrottlingProgramming();
                //Example 1
                 sp2010List.WriteThrottleInformation();

             }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.Read();
        }
    }

    class SP2010ListThrottlingProgramming
    {
        public void WriteThrottleInformation()
        {
            SPWebServiceCollection wsc = new SPWebServiceCollection(SPFarm.Local);
            foreach (SPWebService ws in wsc)
            {
                SPWebApplicationCollection wac = ws.WebApplications;
                foreach (SPWebApplication wa in wac)
                {
                    Console.WriteLine("Web Application: {0}", wa.Name);
                    Console.WriteLine("\tCurrentUserIgnoreThrottle: {0}", wa.CurrentUserIgnoreThrottle());
                    Console.WriteLine("\tIsUnthrottledPrivilegedOperationsAllowed: {0}", wa.IsUnthrottledPrivilegedOperationsAllowed());
                    Console.WriteLine("\tMaxItemsPerThrottledOperation: {0}", wa.MaxItemsPerThrottledOperation);
                    Console.WriteLine("\tMaxItemsPerThrottledOperationOverride: {0}", wa.MaxItemsPerThrottledOperationOverride);
                    Console.WriteLine("\tMaxItemsPerThrottledOperationWarningLevel: {0}", wa.MaxItemsPerThrottledOperationWarningLevel);
                    Console.WriteLine("\tMaxQueryLookupFields: {0}", wa.MaxQueryLookupFields);
                    Console.WriteLine("\tUnthrottledPrivilegedOperationWindowEnabled: {0}", wa.UnthrottledPrivilegedOperationWindowEnabled);
                    Console.WriteLine("\tDailyStartUnthrottledPrivilegedOperationsHour: {0}", wa.DailyStartUnthrottledPrivilegedOperationsHour);
                    Console.WriteLine("\tDailyStartUnthrottledPrivilegedOperationsMinute: {0}", wa.DailyStartUnthrottledPrivilegedOperationsMinute);
                    Console.WriteLine("\tDailyUnthrottledPrivilegedOperationsDuration: {0}", wa.DailyUnthrottledPrivilegedOperationsDuration);
                  }
             }
        }           
    }
}

SharePoint 2010 List Throttling  (899 Views)