logo
search
list

Table of Content

Does SharePoint createAllItemsQuery Bypass the 5000-Item Threshold?

Posted by Algirdas Jasaitis

calendar

2026-08-30

views

868

likes

59

Resolve SharePoint 5000-Item Threshold Errors in CAML Queries

Learn how to bypass SharePoint's 5,000-item threshold errors using createAllItemsQuery overloads, batch pagination, and indexed column filters.

Encountering the dreaded 5,000-item limit error when querying large SharePoint lists can be frustrating, especially when you expect your code to handle bulk operations automatically.

Problem Description: List View Threshold Blocks

Many developers assume that using SP.CamlQuery.createAllItemsQuery() in SharePoint's JavaScript Object Model (JSOM) automatically circumvents the standard list view limits. However, this method does not bypass the 5,000-item threshold. When executed on large datasets without proper parameters, it triggers a server-side threshold error, preventing the query from completing and leaving your application without the requested data.

Quick Answer for CAML Query Limits

To fix this, stop querying the entire list at once. Instead, use the createAllItemsQuery(rowLimit, viewFields) overload to fetch items in smaller batches, implement ListItemCollectionPosition for pagination, and ensure you are filtering against indexed columns to prevent full table scans.

Likely Causes Behind Large List Query Failures

  • Server-Side Protection: SharePoint enforces a strict 5,000-item query limit to prevent SQL Server database locks and maintain tenant performance.
  • Full Table Scans: Querying a list without specific, indexed filters forces SharePoint to scan every single row, immediately triggering the threshold block.
  • Unparameterized Queries: Using the default createAllItemsQuery() without passing a rowLimit parameter defaults to fetching all items, which fails on massive lists.

Recommended Solution: Safely Querying Massive Datasets

  1. Index Your Columns: Before modifying your code, navigate to your SharePoint List Settings. Under "Columns," select Indexed Columns and create an index for the specific fields you plan to filter by. (Note: You cannot index a column if the list already exceeds 20,000 items without intervention).
  2. Apply the Overload Method: Update your JavaScript code to define a strict row limit using the overload parameter. For example: var camlQuery = SP.CamlQuery.createAllItemsQuery(2000, ['Title', 'ID']);
  3. Implement Pagination: Use the ListItemCollectionPosition property to page through the results. Once the first batch of 2,000 items is returned, capture the position token.
  4. Loop the Query: Pass the captured position token back into your camlQuery.set_listItemCollectionPosition() for the next request. Repeat this loop until the returned position token is null, indicating all items have been retrieved.

Alternative Solutions for Extracting High-Volume Data

  1. Use the SharePoint Search API: If you only need to read data (and real-time accuracy down to the second isn't strictly required), the SharePoint REST Search API is designed to query millions of items without hitting standard list view thresholds.
  2. Power Automate Data Extraction: Offload the heavy lifting to a scheduled Power Automate flow. Set the "Get Items" action with Pagination turned on in the settings to automatically batch and process items into a separate database or file.

Working with WPS Office: Managing Exported SharePoint Data

While third-party client software cannot override Microsoft SharePoint's server-side limits, you will often need a robust tool to analyze the massive datasets you successfully extract. If you export your paginated SharePoint data into CSV or Excel formats, WPS Office serves as an excellent, lightweight alternative to Microsoft Excel. WPS Spreadsheet easily handles large data files, offering advanced filtering, pivot tables, and seamless compatibility with Microsoft formats for fast local data analysis—completely free of charge.

Prevention Tips for Future Data Bottlenecks

  • Proactive Indexing: Always index your primary filtering columns when creating a new list, well before the item count reaches 5,000.
  • Data Archiving: Regularly move obsolete items to an archive list or a secondary storage solution to keep active list sizes manageable.
  • Logical Folder Structures: While folders do not solve query thresholds directly, they can help segment data visually. Ensure your views are filtered to show items inside folders rather than flattening the list.

FAQs About SharePoint Item Limits

Can a SharePoint Administrator increase the 5,000-item threshold limit?

In SharePoint Online (Microsoft 365), the 5,000-item limit is hardcoded and cannot be changed by administrators. In SharePoint Server (On-Premises), farm administrators can technically increase it via Central Administration, but doing so is highly discouraged as it degrades overall SQL database performance.

What exactly is a "full table scan" in SharePoint?

A full table scan occurs when a query asks the database to read every single row in a table to find matching items, rather than using a pre-calculated index. SharePoint blocks these operations if they involve more than 5,000 rows to protect server resources.

Why does my list view work, but my CAML query fails?

Modern SharePoint list views automatically manage pagination and indexing behind the scenes. Custom CAML queries via JSOM or REST require you to manually define these efficiency parameters; otherwise, they default to resource-heavy requests that the server rejects.

Algirdas Jasaitis

15 years of office industry experience, tech lover and copywriter. Follow me for product reviews, comparisons, and recommendations for new apps and software.