You need to sign in to do that
Don't have an account?
Jagannath Kasula
Can we use sysmodstamp instead of lastmodifieddate in soql where clause
Can we use sysmodstamp instead of lastmodifieddate in soql where clause
ex: select id from object where sysmodstamp > sampledate
currently we have in batch class is , select id from object where lastmodifieddate > sampledate
we need to fetch large volumes from custom object and currently while fetching records using lastmodifieddate is getting timedout in batch apex, can i replace lastmodifiedate to sysmodstamp as it is an index field.
ex: select id from object where sysmodstamp > sampledate
currently we have in batch class is , select id from object where lastmodifieddate > sampledate
we need to fetch large volumes from custom object and currently while fetching records using lastmodifieddate is getting timedout in batch apex, can i replace lastmodifiedate to sysmodstamp as it is an index field.
LastModifiedDate is the date and time when a record was last modified by a user, and SystemModstamp is the date and time when a record was last modified by a user or by an automated process (such as a trigger). In this context, "trigger" refers to Salesforce code that runs to implement standard functionality, rather than an "Apex trigger".
As a result, LastModifiedDate and SystemModstamp will differ when automated processes update the records, which will happen in the following scenarios (asynchronously in some cases):
a) The archive date is extended to greater than 365 days.
b) An existing picklist value is updated (not replaced with an existing picklist value).
c) A contact's e-mail address is flagged as per the Email Bounce Management configuration.
d) The LastActivityDate field is modified
e) Roll-up summary field is created, which will update all the parent records' SystemModstamp asynchronously. Recalculation will also take place if the Summary Type is updated.
f) Some Salesforce Internal backend processes also update SystemModstamp as SystemModstamp is used internally to signal that a record (or related data) may have changed and that internal processes may need to synchronize themselves to the new record data.
For more information on how a SOQL query's performance can be impacted by the use of each field refer to this
https://developer.salesforce.com/blogs/engineering/2014/11/force-com-soql-performance-tips-systemmodstamp-vs-lastmodifieddate-2.html
Below are differences between sysmodstamp and lastmodifieddate.
LastModifiedDate is automatically updated whenever a user creates or updates the record. LastModifiedDate can be imported with any back-dated value if your business requires preserving original timestamps when migrating data into Salesforce.
SystemModStamp is strictly read-only. Not only is it updated when a user updates the record, but also when automated system processes update the record. Because of this behavior, it creates a difference in stored value where ‘LastModifiedDate <= SystemModStamp’ but never ‘LastModifiedDate > SystemModStamp’.
Also refer below salesforce document.
https://developer.salesforce.com/blogs/engineering/2014/11/force-com-soql-performance-tips-systemmodstamp-vs-lastmodifieddate-2.html
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.
Best Regards,
Sandhya