You need to sign in to do that
Don't have an account?
njo103
Soql governor limit since winter 16
Hello,
Since winter 16, we are encountering a Salesforce governor limit of 100 soql queries. When looking at the debug log, the following happens :
- Trigger on object that updates the records
- Workflows are triggered
- Trigger on updated records are triggered following workflow updates
However, in this case, for each upated record by the workflow, considering 5 records :
workflow update on 1 record =>trigger is triggered and soql counted
workflow update on 1 record =>trigger is triggered and soql cumulated
on so on for all 5 records
This has become a blocking issue.
Could you please help? Has there been a change in the way Salesforce counts the governor limits?
Thanks,
Nive
Since winter 16, we are encountering a Salesforce governor limit of 100 soql queries. When looking at the debug log, the following happens :
- Trigger on object that updates the records
- Workflows are triggered
- Trigger on updated records are triggered following workflow updates
However, in this case, for each upated record by the workflow, considering 5 records :
workflow update on 1 record =>trigger is triggered and soql counted
workflow update on 1 record =>trigger is triggered and soql cumulated
on so on for all 5 records
This has become a blocking issue.
Could you please help? Has there been a change in the way Salesforce counts the governor limits?
Thanks,
Nive
- DB: DEBUG
- Callouts: NONE
- ApexCode: INFO
- Validation: NONE
- Workflow: NONE
- Profiling: NONE
- Visualforce: NONE
- System: INFO
Then see where you are calling your SOQL queries and are making more than the alloted amount. This typically happens when you have SOQL inside of a loop. If you cannot figure out where your code is going off of the rails, feel free to include the code here and we can try to help you.NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.
The developpement is indeed a very old developement that could certainly be optimized but so far it worked well with bulk.
I understand that the soql queries are cumulative but are they cumulated per record updated by the workflow field updates?
Does that mean that if my trigger size is 500 records and worfklows are triggered for those 500 records that in turn would trigger my triggers on that particular object, the governor limits would be cumulated per record following the worfklow update per record?
If you did a dataload that inserted 20 leads the flow would go
- before insert trigger fires (20 SOQL queries)
- workflows fire (workflow updates an unrelated field on the Lead)
- before update triger fires (20 SOQL queries)
At the end of this cycle we've used a total of 40 SOQL queries.Where we've run into problems with older code that has not bulk ready is that for a long time it'll run fine for a long time (even with bulk operations) but then we'll add a single new trigger or workflow (or even the data changes slightly) and where we were hovering at 98 queries now we've been pushed over the threshold to 100+ queries.
Where I would start to diagnose the issue is to change your log levels in the debug log, do your operation and then look through the logs to see where your SOQL governor limits suddenly spike. Then look at that trigger and see if you can make it bulk ready. Then repeat until your SOQL limits are low enough for comfort. Then put in place a plan to review all old triggers and make then bulk ready. Possibly look at implementing a trigger framework [1] and using lazy loading [2] to reduce some of your total SOQL queries.
[1] http://blog.deadlypenguin.com/blog/2012/02/13/classifying-triggers-in-salesforce/
[2] http://blog.deadlypenguin.com/blog/2012/04/04/reducing-salesforce-soql-queries-by-using-static-variables/
Please find below part of the debug log :
As you can see the afterUpdate on the opportunity updates existing tasks on the opportunity and the update has been done for a list of tasks.
However, the workflow that is then triggered on the tasks cumulates the queries PER record. If i have 50 tasks, then am already close to my SOQL limit.
I do not understand why this is being cumlated per record.
Thank you for your help.
But when trying to regenerate a debug log to check what was trigger the updates per record, the issue no longer existed and the update got through without errors.