0

We can call another batch from the finish method of one batch, then why do we need Queueable apex

1
  • 1
    Technically, batch should be called if we are having huge data for processing. However, sometimes there are some tasks are compute intensive, which shall be called with Queueable. And IMHO - Batch goes through different stages than queueable. Batch has start/execute[which will iterate over chunk size]/finish and next batch will be called. but in queueable it'll be straight forward, once you complete current processing you can initiate another processing(no need to wait for start/finish kind of stuffs). – Ysr Shk Apr 8 at 9:30
5

They just have different use cases.

  • Most crucially, you can have only 100 batch jobs pending at any given time. I do not believe any such limit exists for Queueable jobs.
  • Queueable jobs will also tend to execute faster as they have less overhead to deal with (no start/finish).
  • Generally, batches should be used to act over moderate to large database queries, whereas Queueables should be used to execute smaller increments of work more quickly.
1

Queuable Advantage:

  1. Queueable can run parallelly and there no limit for chaining. While in a batch there is a limit of 100 batches
  2. Queueable can be much faster than batch apex if used properly
  3. This can be invoked from future method as well

Batch Advantage:

  1. Batch allows to query up to 50 million records in a start method (This is unique)
  2. Can define the scope and can be run at a time 2000 records with batch size
  3. Batch allows to track all the bulk records by using a database.stateful
  4. Cannot be invoked from future method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.