Skip to main content
All CollectionsData backup and ArchivingManaging a data backup job
What is Gearset PK chunking and should I use it?
What is Gearset PK chunking and should I use it?

Find out what Gearset PK chunking does and whether it would beneficial to switch it on for your team.

Samantha Eastwood avatar
Written by Samantha Eastwood
Updated over 2 months ago

Salesforce PK Chunking

Before we talk about Gearset PK Chunking, it's helpful to first look at Salesforce PK Chunking.

In areas of Gearset where we deal with large data retrieval from Salesforce, such as data backup, we can sometimes experience query timeout exceptions from Salesforce. When this happens, Gearset automatically retries the retrieval with Salesforce PK (primary key) chunking enabled.

With Salesforce PK chunking, a large query will be split into multiple smaller 'chunks' based on the ids (i.e. primary keys) of the queried records. (A more detailed explanation of how queries are broken down in Salesforce PK chunking can be here.) This helps avoid timeout exceptions as each query is smaller and more manageable.

However, Salesforce PK chunking is only supported for some objects. This is where Gearset PK chunking comes in.

Gearset PK Chunking

To handle timeout exceptions occurring in objects without Salesforce PK chunking support, we roll our own PK chunking strategy internally within Gearset.

Gearset PK chunking uses a similar strategy to Salesforce PK chunking, in that it also breaks large queries down into smaller 'chunks' by limiting the number of records queried and using the record ids to delimit the chunks. This reduces the chance of hitting timeout exceptions for similar reasons to Salesforce PK chunking.

The primary difference between the two is how they are enabled "under the hood". For Salesforce PK chunking, there is just a configuration in the header for the Bulk API query that needs setting. For Gearset PK chunking, Gearset has to modify the requests sent via the Bulk API to have limits on the number of records and the record ids to use.

Currently, Gearset PK chunking is only supported for a specific set of objects that we have identified as frequently causing timeouts for users:

  • AccountPartner

  • CEACount__History

  • ContentDistribution

  • ConversationContextEntry

  • CreditMemoLine

  • OrderDeliveryGroup

  • OrderItemAdjustmentLineItem

  • PackageSubscriber

  • Partner

  • Product_Feature__History

  • ServiceReport

  • SocialPost

  • SurveyInvitation

  • SDOC__SDoc__c

Do I need to enable Gearset PK Chunking?

Most customers do not need Gearset PK chunking on by default. Enabling Gearset PK chunking can make backup jobs significantly slower, so if it's not necessary it's better to not enable it. However, if you're experiencing frequent timeout exceptions in your data backup jobs, such as the one below, it's worth turning it on to see if it will fix the issue.

Gearset PK chunking can be enabled for your team in Account Settings on the Data Management page:

Note that you must be a team owner to be able to see this setting.

I'm still having issues even with Gearset PK chunking on.

There's a few reasons you could still be facing query timeouts despite turning on Gearset PK chunking:

  • The main objects causing issues in your data backup job may not have Gearset PK chunking support, in which case turning on the setting will not have changed how Gearset retrieves it.

  • It's possible that the issue is related to permissions instead: We've noticed that retrieving data with a Salesforce user who doesn't have the full set of system permissions for data retrieval (View all data, Modify all data, Query all files) can exacerbate timeout issues.

  • Finally, while reducing chunk sizes significantly reduces the chance of timeout issues in most cases, there are some objects where retrieving small chunks will still fail.

If you're continuing to have issues with query timeouts, please reach out to Gearset support through the in-app widget.

Did this answer your question?