Question:
How is Call Chunking used to Improve CRM Query Performance?
Answer:
If the Call Object query is timing out during a sync, it may be helpful to implement Call Chunking in order to improve query performance. Chunking breaks up the query into multiple smaller queries. The parameter for chunking is: &&LAST_N_DAYS&&, a reference to the SOQL date literal LAST_N_DAYS.
Chunking is implemented on the WHERE statement of the Call Object VMOC. A common WHERE statement on the Call object is:
WHERE Call_Date_vod__c >= LAST_N_DAYS:60
To Chunk this statement, The Veeva &&LAST_N_DAYS&& tag requires at least 3 arguments, separated by colons:
-
API name of the date or dateTime field to be used.
-
Total number of days to be queried.
-
Number of days in a single chunk.
-
(Optional) Number of days to chunk into the future.
For example, to modify the 60-day call-history to query 10 days at a time, the WHERE clause would be modified to:
WHERE &&LAST_N_DAYS:Call_Date_vod__c:60:10&&
On the server, this is converted to six historical queries and one future query:
WHERE (Call_Date_vod__c >= 2013-03-30 AND Call_Date_vod__c < 2013-04-09)
WHERE (Call_Date_vod__c >= 2013-04-09 AND Call_Date_vod__c < 2013-04-19)
WHERE (Call_Date_vod__c >= 2013-04-19 AND Call_Date_vod__c < 2013-04-29)
WHERE (Call_Date_vod__c >= 2013-04-29 AND Call_Date_vod__c < 2013-05-09)
WHERE (Call_Date_vod__c >= 2013-05-09 AND Call_Date_vod__c < 2013-05-19)
WHERE (Call_Date_vod__c >= 2013-05-19 AND Call_Date_vod__c < 2013-05-29)
WHERE (Call_Date_vod__c >= 2013-05-29)
Related Documentation:
N/A