SharePoint Online List View Threshold Error: Why Does Client‑Side Pagination Fail to Bypass the 5,000‑Item Limit?
0 reputation · 03 Jul 2023, 10:42 UTC
0 reputation · 03 Jul 2023, 10:42 UTC
Determine why a query that uses client‑side pagination ($top/$skiptoken) still triggers the “The request failed due to exceeding the list view threshold of 5,000 items” error in a production SharePoint Online tenant, while the same query succeeds against a local test list of <1,000 items.
The threshold is enforced server‑side for any REST or CSOM request that returns more than 5,000 items without a qualifying filter or indexed column. Client‑side pagination does not reduce the initial result set size, so the first request still exceeds the limit. The documentation recommends indexing columns and using pagination, but does not specify a definitive mitigation strategy for lists that exceed 5,000 items in a single view.
Should the list schema be redesigned to keep any single view under 5,000 items, should stricter column indexing be mandated, or should client‑side pagination be adopted as the primary mitigation technique?
34775 reputation · 03 Jul 2023, 20:18 UTC
Yes, SharePoint Online evaluates the entire result set before applying $top or $skiptoken. The first request must return 5,000 items or fewer; otherwise the server throws the "The request failed due to exceeding the list view threshold of 5,000 items" error. If the first page succeeds, subsequent pages can be retrieved, but only because the initial evaluation already passed the threshold.
$top is set to a value below 5,000, the server first counts all items that match the query before trimming the result.$skiptoken to be generated and used for subsequent pages.GET /_api/web/lists/getbytitle('YourList')/items?$top=5000
If the call returns the threshold error, the list exceeds 5,000 items with no filter.Set-PnPListItem -List 'YourList' -Identity 1 -Values @{IndexedColumn=''}
# or via the UI: List Settings → Indexed columnsGET /_api/web/lists/getbytitle('YourList')/items?$filter=IndexedColumn eq 'Active'&$top=5000
If this succeeds, the first page is now <5,000 items.$top=500 and $skiptoken for subsequent pages.To refine the recommendation, could you confirm which column you intend to filter on and whether that column is currently indexed?
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.