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
jpwagnerjpwagner 

Script Statement governor limit

Hi all,

 

I think I must be misunderstanding something about some of the governor limits.

 

Here's a quick example of something I'd like to understand better:

 

I have a trigger that does a bunch of calculations on insert and update of a custom object and inserts some new records based on those calculations.  When I split up my ~52,000 record initial dataset, and load (via the APEX Data Loader)~13,000 records 4 times, I have no governor limit breaches.  When I load all 52,000 at once, it breaks the Script statement governor limit. 

 

I thought the APEX data loader batches it's loads into 200, so how is this possible?

Message Edited by jpwagner on 04-13-2009 11:37 PM
werewolfwerewolf

That's not possible.  Something there isn't right.

 

Are you sure it's an Apex limit you're hitting and not, say, the API transaction limit?

jpwagnerjpwagner

I'm positive that this is what I saw, but I should clarify the facts:

 

I inserted the entire dataset first and received ~60 emails with the script statment limit breach.

 

I then upserted the 13,000 batches (but the trigger fires on insert and update, so the same code should be executed).

Each of the 4 times, I received zero emails about governor limits.

 

Not sure if that helps. 

 

Is it possible the insert of the record is more "expensive" than the update?  (ie, there could be internal processes eating up script statements, correct?)

 

 

 

If not, I'll look over my dataset/code again because I must've missed something. 

werewolfwerewolf

I'm guessing there's a red herring in there somewhere.  One or more specific batches are failing (probably 60 of them) -- the evidence of that is that you got 60 emails and not just one.  So it may seem like it has to do with the batching, but maybe it's just the way the records are grouped somehow?

 

Perhaps you can recreate one of the specific batches that failed and rerun that.  Then you could turn on the debug log and watch it execute, and you may find a loop or something that's blowing out under certain circumstances.

 

Inserts are not "more expensive" than update -- you get your 20 queries and 10000 or whatever script statements on both regardless of what the underlying system is doing.

jpwagnerjpwagner

Thanks, I'll debug my stuff.

 

 

 

One point of clarification since you misunderstood my "expensive" comment:

 

I'm not suggesting that what triggers the apex code matters, but rather the statements themselves.

 

Is

 

"if(somelist.size()>0){insert somelist;}"

 

truly ONE scriptstatement?

or 1.15

or 1.7324...whatever.

 

but I was wondering if whatever it is was greater than:

 

"if(somelist.size()>0){update somelist;}"

 

I could be way off here, but I could not find in documentation anywhere that Apex code defines:

 

"Integer n = 0;"

 

as exactly ONE scriptstatement. 

 

for all i know scriptstatement size could be a function of heap size.

werewolfwerewolf
Oh.  As far as I know one statement is equal to exactly one statement, no matter what it is.  Different limits apply to inserts and updates (as in they count towards the DML limits), but as statements they're just statements.