sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

List view threshold exceeded for unfiltered list retrieved by REST API

Open tasktop-integrations opened this issue 5 years ago • 5 comments

Category

  • [x] Question
  • [ ] Typo
  • [ ] Additional article idea

Question

We're attempting to retrieve all items in a list via the REST API. We first attempt to retrieve the items using a filtered request. If that fails due to the query exceeding the list view threshold, then we attempt to retrieve the items using an unfiltered request. In theory this should not hit the threshold due to the request not needing to do any processing of rows before returning the result. In testing, this has worked for us but for one of our customer's environments, we see the list view threshold limit being hit for both requests.

Filtered request: GET <host>/_api/web/lists(guid'4c2ce93b-5e2d-4e68-8489-84811c0cee4b')/items?$filter=ContentTypeId%20eq%20'0x0103002EDC6A0548FF8C41BC0F8B06A556077F'&$orderby=Modified%20desc&$select=Id,Title Response: 500 Internal Server Error { "error":{ "code":"-2147024860, Microsoft.SharePoint.SPQueryThrottledException", "message":{ "lang":"en-US", "value":"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator." } } }

The subsequent unfiltered request: GET <host>/_api/web/lists(guid'4c2ce93b-5e2d-4e68-8489-84811c0cee4b')/items?$select=Id,Title,ContentTypeId Response: 500 Internal Server Error { "error":{ "code":"-2147024860, Microsoft.SharePoint.SPQueryThrottledException", "message":{ "lang":"en-US", "value":"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator." } } }

Is there a configuration on the server or any reason that the unfiltered request would throw this exception?

Environment details (development & target environment)

  • Your Developer Environment: [Mac OS 10.15.7]
  • Target Environment: [SharePoint Server 2013]
  • Framework: [REST]
  • Browser(s): [n/a]
  • Tooling: [n/a]
  • Additional details: This issue is on behalf of a customer - I don't have access to the Sharepoint instance directly but can get more info if needed.

tasktop-integrations avatar Mar 17 '21 18:03 tasktop-integrations

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Mar 17 '21 18:03 ghost

That's the threshold limit in SharePoint. By default, the list view threshold is configured at 5,000 items. When we try to access more than 5000 items at a time, which is the default threshold limit, we would get this error. This issue also happens when we try to access items using the OOB list view web part

Michael Han Microsoft SharePoint Community Support

michaelhan-1 avatar Mar 18 '21 06:03 michaelhan-1

Hi, thanks for the response. I'm aware of the threshold, the issue is that the threshold error is thrown even when the request is unfiltered. I've seen from testing on my own system for a list with more items that the threshold that a filtered request will throw the error, but an unfiltered request will return a valid response. My understanding is that the definition of the threshold "the maximum number of list or library items that a database operation, such as a query, can process at the same time" means that the threshold should not be an issue for large lists if the query is unfiltered, because there is no processing needed. The problem is that for a different environment than I'm testing on, I'm seeing the threshold error being thrown with the unfiltered query. Is there a configuration or setting that might cause this?

tasktop-integrations avatar Mar 18 '21 16:03 tasktop-integrations

@tasktop-integrations said:

... the threshold error is thrown even when the request is unfiltered.

That's irrelevant... the threshold limits are in place for ANY query. Filtering makes no difference... in the threshold. The recommendation is to use filtering for your views to limit the result set returned to be under the threshold limits.

andrewconnell avatar Mar 23 '21 09:03 andrewconnell

Closing this issue as "answered". If you encounter a similar issue(s), please open up a new issue. See our wiki for more details: Issue-List: Our approach to closed issues

ghost avatar Mar 26 '21 10:03 ghost