Thursday 11 June 2015

Overcoming the Threshold limit of Lists in Office 365 (SharePoint Online) .

In office 365 i.e. SharePoint Online You can sync up to 5,000 items in site libraries, including folders and files.   This is the List View Threshold, which blocks most list and library operations when this limit is exceeded. That means that you cannot retrieve more than 5000 rows (records) in a single fetch.

When you do filtering in a list and upon filtering the result set crosses the threshold limit enforced you will get an error message.

In order to sort out the issue we should create Indexes on some columns in that particular list.

Create a filtered view with a column index

A filtered view with a column index is not only a way to retrieve items more efficiently, but a primary method of working with large lists and libraries without getting blocked. Creating a filtered view with an indexed column is a two-step process: create an index for a column and create a view that uses the indexed column to filter the view:
  • Indexes    An index retrieves items quickly and can improve list and library performance. You can create up to 20 indexes for a list or library. Unique values require an index and the ID column is automatically indexed. Because each index adds some overhead to every database operation to maintain the index, it’s best to only add indexes for the most common or likely columns used to query the list or library.
  • Filtered views   When you create a filtered view, make sure that the first column in the filter expression is indexed and that the filtered view does not exceed the List View Threshold. Other columns you specify in the view filter may or may not be indexed, but the view does not use those indexes, even if the final result of the filtered view returns less than the List View Threshold. If you use two or more columns in the filter expression, use an AND operator but make sure the first column in the expression returns the lesser amount of data.
Create a filtered view with a column index
  1. Sign into Office 365 and navigate to the site that contains the list or library.
  2. Click its name on the Quick Launch, or click on the Settings menu Settings button , click View All Site Content, and then click the name.
To create a simple index
  1. Click List or Library > List Settings or Library Settings.
  2. Under the Columns section, make note of the type for each column. Make sure you select a supported column type in step 5.
    Supported Column Types
    • Single line of text
    • Choice (single value)
    • Number
    • Currency
    • Date and Time
    • Person or Group (single value)
    • Managed Metadata
    • Yes/No
    • Lookup
    Unsupported Column Types
    • Multiple lines of text
    • Choice (multi-valued)
    • Calculated
    • Hyperlink or Picture
    • Custom Columns
    • Person or Group (multi-valued)
    • External data
    NOTE   Although you can index a lookup column to improve performance, it does not prevent exceeding the List View Threshold. Also, indexing the "looked up" column in the other list or library does not improve the performance of the lookup operation.
  3. Click Indexed columns.
  4. On the Indexed Columns page, click Create a new index.
  5. In the Primary Column section, under Primary column for this index, select a supported column type from step 2.
    NOTE   A compound index is based on two columns, primary and secondary, and can use either column to access the data quickly. To create a compound index, in the Secondary Column section, under Secondary column for this index, select a different supported column type. Compound indexes are not used by filtered views to prevent blocking, but they are used with metadata navigation.
To create a filtered view
  1. In the ribbon, under List Tools or Library Tools, click the List or Library tab.
  2. In the Managed Views group, click Create View.
  3. Click the option, such as Standard View or an existing view that you want to use to create your view.
  4. In the View Name box, type the name for your view.
  5. Select Make this the default view if you want to make this the default view for the list or library. Only a public view can be the default view for a list or library.
  6. In the Filter section, click Show items only when the following is true, and then choose how you want to filter the items based on one of the columns that is indexed. For example:
    To view
    • Items changed in the past week.
    • Items added before last week
    • My items
    • Items due today
    • Items updated in the past month
    • Items ready for archiving
    • Items from Mexico
    • Items beginning with "D"
    • Items from 2008 and the NorthEast.
    Filter by (Indexed column in bold)
    • Modified is greater than  [Today]-7.
    • Created is less than [Today]-7.
    • Created By is equal to [Me].
    • Due Date is equal to [Today].
    • Last Updated is greater than [Today]-30.
    • Date Modified is less than December 31st 2006.
    • CountryRegion equals Mexico .
    • Name Starts with D.
    • Region equals "NE" AND Year equals 2008.
      Region has less values than Year.
  7. Choose any other options that you want for your view, such as which columns you want to show or hide and how you want to sort the items.
    For more information on views, see Create, change, or delete a view of a list or library.
  8. Click OK.
    NOTE   If a list or library has RSS support enabled, the RSS Feed uses the default RSS view, which filters the results based on the date values in the Modified column. For a large list or library, it's a good idea to index the Modified column. You can also reduce the number of items retrieved by changing the number of items and number of days for which changes are included in an RSS Feed. For more information, see Manage RSS feeds for a site or site collection.     
To retrieve the Items Programmatically using C# follow this link:
http://expert-sharepoint.blogspot.in/2015/06/get-list-data-from-sharepoint-list-when.html


No comments: