I have a simple reparenting before insert trigger that is going to update a single field on each record.

About 9,000,000 records are going to be inserted every morning and then deleted later that night (Please do not hurt me). I figure Apex processes 200 records at a time, and this is a before insert trigger so the field update wont count against the per transaction DML Statement Limits (just 200 for the insert operation).

So in theory this should go smoothly. 9,000,000/200 = 45000 "transactions", correct?

Anything I should consider to make this more efficient?

  • Not really sure what exactly you are asking. Are you asking if there is anything you can do in your trigger to make processing the records not so rough?
    – dphil
    Commented May 11, 2016 at 20:02
  • Yes, I feel like the system pocessing cost associated with 45,000 transactions has to be considered poor practice. I am limited to completing this process within Salesforce unfortunately (I do not have control over the csv, the business unit owns that). Commented May 11, 2016 at 20:35
  • 1
    note that data loader supports Bulk API developer.salesforce.com/page/…
    – cropredy
    Commented May 12, 2016 at 18:16
  • @cropredy Thank you, you have just massively expanded my thought process (seperate project, that could use this). This is why I love SFSE! Commented May 12, 2016 at 19:03

1 Answer 1


Using trigger for updating a single field in a record is not advised. You could do that in the csv file itself and upload the data using Data Loader which will reduce the trigger, its helper(if any) ant its test class from your org.

As well it will help the transaction to increase by few milliseconds as invoking apex trigger for each batch(200) of records occupy some CPU usage.

I would suggest you to remove the trigger altogether and do the manipulation in your file itself and upload it to salesforce.

Hope i make some sense.

  • That was my original plan but the business unit is blocking me from doing so, this data is being "sucked" up from a common shared drive. Commented May 11, 2016 at 20:36
  • If you don't have any other viable workarounds, go with your trigger approach. Commented May 11, 2016 at 20:39
  • 3
    My 2 cents. If it's on a common drive why can't you just have something like Talend Open Studio that just picks the new file up when it appears does the transformation and pushes it straight into Salesforce? Sounds like a daily job anyway so assuming there must be some kinda of automation? Or is it manually done every morning?
    – Francis
    Commented May 11, 2016 at 22:37
  • 1
    @Francis Its going to be automated (Data Loader via CLI). The business unit (Politics) controls things outside of Salesforce unfortunately. Commented May 12, 2016 at 18:30
  • Same problem I have :) But I managed to get it in on a technicality that the output from Talent is Java code which you can edit and then compile yourself so it's an "development framework" ... Politics!
    – Francis
    Commented May 12, 2016 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .