PK Chunking and how it works in Salesforce?

PK stands for Primary Key. The primary key is the object's RecordID which is always indexed. PK Chunking splits bulk queries on large tables into chunks based on the record IDs, or primary keys, of the queried records. Each chunk is processed as a separate batch that counts toward the daily batch limit.

To enable the feature, you specify the header ‘Sforce-Enable-PKChunking‘ on the job request for your Bulk API query.

Sforce-Enable-PKChunking
        


How PK Chunking works: demonstration

 How PK Chunking works: demonstration


Here are some basic things about PK Chunking

  • PK Chunking can be used with custom objects and most standard objects.
  • The Bulk API chunk size is 100,000 by default. chunkSize header field can be used to configure smaller chunks or larger ones up to 250,000. Larger chunk sizes will use up fewer Bulk API batches but may not perform as well.

Sforce-Enable-PKChunking: chunkSize=250000;        

  • Filtering can be performed while using PK Chunking by simply including a WHERE clause in the Bulk API query. In this case, there may be fewer records returned for a chunk than the number specified in chunkSize.
  • The lower boundary of the chunk can be set with StartRow parameter

Sforce-Enable-PKChunking: chunkSize=50000; startRow=00130000000xEftMGH        


Some query limitations apply that?effectively disable PK chunking?for the specified bulk query job

  1. Filtering on any field with “id” in the field name (ID fields).
  2. Using an "ORDER BY" clause.


#salesforce #apex #salesforcedeveloper #SalesforceDataArchitect

要查看或添加评论,请登录

社区洞察

其他会员也浏览了