+ Start a Discussion
force noviceforce novice 

Governor Limits

If you write a apex class and call it in the trigger, will you be able to avoid the governor limits?
Best Answer chosen by force novice
GlynAGlynA
Triggers are subject to all the synchronous Apex governor limits, and what's worse, they share those limits with any code that runs in the same transaction.  This can include other triggers on the same object for the same event (insert, update, delete, undelete); if the trigger does DML, then triggers on those objects; if workflow field updates run, then the triggers might run a second time; and so on.

If you need to do a lot of processing in a trigger, you can call an @future method.  This will run as a separate transaction, asynchronously, at some time in the future (indeterminate, but usually not more than 5 seconds or so).  Asynchronous Apex has some higher limits; notably, they get 60 seconds of CPU time instead of just 10.  Batch Apex lets you work with up to 50 million records (2000 at a time).  @readonly methods can access 1 million records, but they can't do any DML.

Which of the governor limits are you trying to get around?

Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy@blogspot.com
Twitter: @GlynAtClosedWon

All Answers

Norm Sherman SFNorm Sherman SF
Nope, there is no way around it!

GlynAGlynA
Triggers are subject to all the synchronous Apex governor limits, and what's worse, they share those limits with any code that runs in the same transaction.  This can include other triggers on the same object for the same event (insert, update, delete, undelete); if the trigger does DML, then triggers on those objects; if workflow field updates run, then the triggers might run a second time; and so on.

If you need to do a lot of processing in a trigger, you can call an @future method.  This will run as a separate transaction, asynchronously, at some time in the future (indeterminate, but usually not more than 5 seconds or so).  Asynchronous Apex has some higher limits; notably, they get 60 seconds of CPU time instead of just 10.  Batch Apex lets you work with up to 50 million records (2000 at a time).  @readonly methods can access 1 million records, but they can't do any DML.

Which of the governor limits are you trying to get around?

Glyn Anderson
Sr Developer | System Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator
Blog: GlynATheApexGuy@blogspot.com
Twitter: @GlynAtClosedWon
This was selected as the best answer