# How to Solve OPERATION\_TOO\_LARGE Errors

## How to Solve OPERATION\_TOO\_LARGE Errors

If CopyStorm is reporting an OPERATION\_TOO\_LARGE error, it will be included in the CopyStorm log. The error will look like this:

09:02:11: \[UnexpectedErrorFault \[ApiFault exceptionCode=’OPERATION\_TOO\_LARGE’ exceptionMessage=’exceeded 20000 distinct ids’ extendedErrorDetails='{\[0]}’ ] ] Before diving into the root cause, this is the most common solution:

* Grant the ViewAllData privilege to the Salesforce credentials being used with CopyStorm.

## Root Cause

The root cause of this exception can be found in the Salesforce description of the error:

* `OPERATION_TOO_LARGE`

The query has returned too many results. If certain queries are run by a user without the “View All Data” permission and many records are returned, the queries require sharing rule checking. For example, consider queries that are run on objects, such as [Task](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_task.htm), that use a polymorphic foreign key. These queries return this exception because the operation requires too many resources. To correct, add filters to the query to narrow the scope, or use filters such as date ranges to break the query up into a series of smaller queries.

You can find the Salesforce documentation in the [Core Data Types](https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm) section.

Almost all CopyStorm sites will want to use Salesforce credentials with the ViewAllData permission because without this permission all data will not be backed up. In particular, no metadata will be backed up because the API call used to fetch metadata requires the ViewAllData permission.

## I Need a Timebox Approach Because ViewAllData is Not Allowed

If your organization does not want to give your CopyStorm backup user the ViewAllData permission and an incomplete backup is OK, you can configure CopyStorm to backup data using a sliding timebox.

For example, to backup the Note table using a 60 day sliding timebox, the following TableRule must be added to your site’s [TableRuleRegistry.xml](/reference/configuration-files/how-to-set-table-specific-processing-options.md) file:

```
<TableRule name="Note"  timestamp="LastModifiedDate" timebox="60" timeboxEpoch="2001-01-01" />
```

This XML rule means:

* Use a sliding 60 day window when backing up Note.
* Start the first search on 1-Jan-2001.
* Start subsequent searches at the timestamp on the most recent Note record in the backup.

The system will backup Note records in roughly the following order:

1-Jan-2001 thru 28-Feb-2001 1-Mar-2001 thru 30-Apr-2001 1-May-2001 thru 30-Jun-2001 etc… until the current date is reached.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/reference/configuration-files/how-to-solve-operation_too_large-errors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
