Blog
SharePoint - how to fix list threshold errors when working with very large lists
April 1. 2021
When we attempt to filter large SharePoint lists, the operation may fail with the error "The attempted operation is prohibited because it exceeds the list view threshold". This post describes this error, including how to fix this problem.
Although SharePoint can handle large quantities of data, querying large lists can be difficult. Query delegation limitations cause the most problems, and list threshold values can also cause difficulties for app builders.
What is a list view threshold?
How can we filter/sort lists in Power Apps without this error?
Demonstration of problem
To demonstrate the problem, let's look at an 'auto-generated' app that connects to a SharePoint list called clients. There are 40,000 records in this list.
We can immediately see the problem. The gallery control fails to show any data, and instead shows the error message - "The attempted operation is prohibited because it exceeds the list view threshold"
What's the cause of this problem?
The cause of this problem is that the formula for the gallery control attempts to sort and to filter the list items by the title column.
SortByColumns(Filter([@Client],If we set the items property of the gallery control directly to the client list, the error message disappears, and the gallery control displays the list data correctly.
StartsWith(Title, TextSearchBox1.Text)
),
"Title",
If(SortDescending1, Descending, Ascending)
)
What is a list view threshold?
What exactly is the "list view threshold" that the error message refers to?
The purpose of the list view threshold is to prevent users from querying data in a way that causes an excessive load on the server.
The purpose of the list view threshold is to prevent users from querying data in a way that causes an excessive load on the server.
SharePoint stores its data in a SQL server database. When a user retrieves data from a SharePoint list through Power Apps, SharePoint queries SQL Server to service the request.
SQL Server relies on indexes to retrieve data in an optimal way. If there are inadequate indexes, SQL Server locks the underlying table whilst it executes the query. This causes a severe degradation in performance and concurrency - other users cannot access the data whilst there is a lock. The list view threshold is therefore designed to prevent this locking of data.
SQL Server relies on indexes to retrieve data in an optimal way. If there are inadequate indexes, SQL Server locks the underlying table whilst it executes the query. This causes a severe degradation in performance and concurrency - other users cannot access the data whilst there is a lock. The list view threshold is therefore designed to prevent this locking of data.
How can we filter/sort lists in Power Apps without this error?
We can prevent this error in Power Apps by defining indexes on the columns that we want to filter or to sort.
When we define an index in SharePoint, SharePoint creates a new table in SQL Server that stores the index value for each item in a list. This enables SQL Server to service queries that reference indexed values, without locking the entire list table.
When we define an index in SharePoint, SharePoint creates a new table in SQL Server that stores the index value for each item in a list. This enables SQL Server to service queries that reference indexed values, without locking the entire list table.
To create an index, we navigate to the list settings page in SharePoint. As the screenshot beneath shows, the settings page indicates the number of items in the list, and the default list view threshold value (5,000).
Lower down this page is a link to the 'indexed columns' page. This opens the page shown beneath. If we index the columns that we require, the 'list view threshold' error will no longer appear in Power Apps.
Conclusion
In SharePoint, the list view threshold prevents excessive loads on the server that can cause a degradation in performance and concurrency. We can fix errors that relate to 'list view thresholds' by defining appropriate indexes in SharePoint.
- Categories:
- sharepoint
Related posts
- SharePoint - Deleting the last record from a SharePoint list - how NOT to do this!
- Walkthrough - An beginners guide to building an app that stores images in SharePoint
- SharePoint - What to do when there's a mismatch between times in Power Apps and SharePoint
- SharePoint - Filtering lists by User() is now delegable
- SharePoint - How to fix the "skip to main content" error message on integrated forms, or to fix forms where records don't save
- SharePoint - Use this trick to perform a 'contains' type search in a more delegable way
- Sharepoint - Filtering records by yes/no columns bug - now fixed!
- Configuration - How to set the SharePoint address of a data source with a variable
- Data - How to make a copy of a record
- SharePoint - How to export and import lists and maintain lookup relationships
- Data - How to move SharePoint sites, lists, and data
- Code - Can we hack SharePoint ID columns to be delegable using the greater than/less than operators?
- SharePoint - How to filter records by the current user
- SharePoint - Beware of numeric calculated columns!