You need to sign in to do that
Don't have an account?
Jim Boudreaux
200001 Script Statements, Oh My!
I solved my SOQL Limit problem by looping through the results of one SOQL query.
Now I am running against a Script Statement Limit.
How should I go about optimizing my code to avoid this Limit?
Earlier I ran the same problem and I followed following way to fix the problem
- commented all the System.debug statements in my code
- used break; in my for loop wherever appropriate
- revised my class method code to make shorter
- decreased the batch size for the bulk import
- called the class/methods (for example method related to do some calculations) out of the for loop, if it is possible
- merged related triggers to a single object to single trigger
in my experience - YES
is there a way to break code up into blocks in a way that the governor limits apply to each block?
My problem is this:
I have a custom object that represents a building. Each building has a related list of custom objects that represent floors.
So each building has some floors.
Further I have a custom object that represents a device on a floor in a building.
My controller gets a list of all the floors in a building and a list of devices in a building.
I run into the Script Statement limit when I loop through all the floors and for each floor I loop through the devices and find the devices that are on that floor.
This is fine for most buildings, but I have a 40 story building that is breaking my code. I need to come up with a more robust and scaleable way to do this.