We can call another batch from the finish method of one batch, then why do we need Queueable apex
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.
- Queueable can run parallelly and there no limit for chaining. While in a batch there is a limit of 100 batches
- Queueable can be much faster than batch apex if used properly
- This can be invoked from future method as well
- Batch allows to query up to 50 million records in a start method (This is unique)
- Can define the scope and can be run at a time 2000 records with batch size
- Batch allows to track all the bulk records by using a database.stateful
- Cannot be invoked from future method