Activity Forums Salesforce® Discussions Why to use batch class instead of normal class in Salesforce?

  • Kirandeep

    Member
    August 26, 2020 at 1:36 pm

    Batch class in salesforce is used to run large jobs (think thousands or millions of records!) that would exceed normal processing limits. Using Batch Apex, you can process records asynchronously in batches (hence the name, “Batch Apex”) to stay within platform limits.

  • Anjali

    Member
    August 26, 2020 at 1:43 pm

    There are various reasons why Batch Apex is better than Normal Apex.

    • A Normal Apex uses 100 records per cycle to execute SOQL queries. Whereas, a Batch Apex does the same in 200 records per cycle. So, it is very fast when the execution of SOQL queries is considered.
    • A Normal Apex can retrieve 50,000 SOQL queries but, in Batch Apex, 50,000,000 SOQL queries can be retrieved.
    • A Normal Apex has a heap size of 6 MB; whereas, a Batch Apex has a heap size of 12 MB.
    • When executing bulk records, Normal Apex classes are more vulnerable to encountering errors as compared to Batch Apex. The latter is normally error-less.
  • Pooja

    Member
    August 26, 2020 at 3:49 pm

    Batch class in salesforce is used to run large jobs (think thousands or millions of records!) that would exceed normal processing limits. Using Batch Apex, you can process records asynchronously in batches (hence the name, “Batch Apex”) to stay within platform limits.

  • Marziya

    Member
    August 26, 2020 at 5:14 pm
    • A Normal Apex has a heap size of 6 MB; whereas, a Batch Apex has a heap size of 12 MB.
    • When executing bulk records, Normal Apex classes are more vulnerable to encountering errors as compared to Batch Apex. The latter is normally error-less.

Log In to reply.

Popular Salesforce Blogs