function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashritha ReddyAshritha Reddy 

Batch Apex VS DataLoader

Irrespective of functionality what is differences between Batch Apex &DataLoader
Mahesh DMahesh D
Hi Ashritha,

Basically Apex data loader is a desktop tool and it is meant for data migration between two systems. In other words, when you want to move data between SFDC and some other environment, you go with data loader.
Say like you want to take a weekly backup of the account object and store it on your desktop, then you can use data loader.

Batch Apex is meant for processing of bulk data within SFDC. It should be used when you have some logic that you want to apply on large data volumes within SFDC, but has nothing to do with an external environment.
Say like you want to send an email to all users who have not logged in in the past month, you can use batch apex (assuming your user volume is BIG).



1) Data Loader is used to export/insert/update/delete data in your organisation,
anything that a person does manually i,e. prepare a sheet and load the data given by client etc

Its just a tool to interact with your database and do manipulations

Whereas Batch Apex is apex code which will include your custom logic and do the data manipulations in bulk. Via batch apex you can automate the data processing with very strong level of flexibility.

2) Bulk API is as name suggest is an API which allows you to load data in millions within less duration of time using parallel asych processing

Data loader can be configured to use Bulk API when you have data in huge amount!


For More information:

https://developer.salesforce.com/forums/?id=906F000000092wuIAA

https://success.salesforce.com/answers?id=90630000000giHyAAI

https://success.salesforce.com/answers?id=90630000000gjCfAAI



--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Data Loader:

Data Loader is a client application for the bulk import or export of data. Use it to insert, update, delete, or export Salesforce records. When importing data, Data Loader reads, extracts, and loads data from comma separated values (CSV) files or from a database connection. When exporting data, it outputs CSV files.

The Data Loader is an easy to use graphical tool that helps you to get your data into Salesforce objects. The Data Loader can also be used to extract data from database objects into any of the destinations mentioned above. You can even use the Data Loader to perform bulk deletions by exporting the ID fields for the data you wish to delete and using that source to specify deletions through the Data Loader.

The Data Loader requires the use of the Force.com API. If your Salesforce edition allows the use of the API (Enterprise, Unlimited and Developer Editions), you can download the Data Loader from the Setup menu, under Administer heading - Data Management.

Please go through some of the links below:

https://developer.salesforce.com/page/Data_Loader

https://help.salesforce.com/apex/HTViewHelpDoc?id=data_loader.htm&language=en

https://help.salesforce.com/apex/HTViewHelpDoc?id=inserting_updating_or_deleting_data.htm&language=en

https://www.youtube.com/watch?v=8azP1kuf9IQ

https://www.youtube.com/watch?v=rjuFthPE3jY



Batch Apex:

Batch Apex is mainly to process the existing salesforce records based on certain criteria.
A Batch class allows you to define a single job that can be broken up into manageable chunks that will be processed separately.

When to use Batch Apex
One example is if you need to make a field update to every Account in your organization. If you have 10,001 Account records in your org, this is impossible without some way of breaking it up. So in the start() method, you define the query you're going to use in this batch context: 'select Id from Account'. Then the execute() method runs, but only receives a relatively short list of records (default 200). Within the execute(), everything runs in its own transactional context, which means almost all of the governor limits only apply to that block. Thus each time execute() is run, you are allowed 150 queries and 50,000 DML rows and so on. When that execute() is complete, a new one is instantiated with the next group of 200 Accounts, with a brand new set of governor limits. Finally the finish() method wraps up any loose ends as necessary, like sending a status email.

Sample Batch Apex
1) Start method is automatically called at the beginning of the apex job. This method will collect record or objects on which the operation should be performed. These record are divided into subtasks & passes those to execute method.

2) Execute Method performs operation which we want to perform on the records fetched from start method.

3) Finish method executes after all batches are processed. Use this method to send confirmation email notifications.

Please go through the below links for more information:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm

https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_batch_intro.htm

http://www.infallibletechie.com/2013/01/simple-batch-apex-example-in-salesforce.html

http://www.salesforcetutorial.com/what-is-batch-apex/

http://www.salesforcetutorial.com/running-batch-apex-example/

https://www.youtube.com/watch?v=PmvpMakxpm8

http://blog.shivanathd.com/2013/01/how-to-write-batch-class-in.html

http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html

https://www.minddigital.com/how-to-call-batch-apex-by-scheduler-class-within-salesforce/

Please do let me know if it helps you.


Regards,
Mahesh
Ashritha ReddyAshritha Reddy
thanking u very much mahesh
 
Mahesh DMahesh D
Hi Ashritha,

Please mark it as resolved so that it will be helpful to others in the future.

Regards,
Mahesh