Activity Forums Salesforce® Discussions What are the implications of implementing Database.Stateful in Salesforce?

  • Piyush

    Member
    November 6, 2019 at 5:53 am

    Hi,

    Database.Stateful  is used for keeping state of variable while execution of batch class. The only time you need Database.Stateful is when the execute method modifies a class variable in a way meant to be used across multiple execute methods or in the finish method. The majority of batches you will ever write will not need Database.Stateful. It's important to know that using Database.Stateful will harm your batch's performance, because the class will be serialized at the end of each execute method to update its internal state. This extra serialization results in longer execution time.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos