1

I am coming into this problem in my debug logs. But when I'm reviewing the logs I am only seeing individual reads of SOQL query counts from various apps such as :

Number of SOQL queries: 5 out of 100

And I have Flows running - but I don't see a cumulative count on the SOQL query limits - just all of the sudden this :

EXCEPTION_THROWN|[EXTERNAL]|System.LimitException: Too many SOQL queries: 101

I would like to determine what is running up the query count, but I don't see where it's building up.

Also - are Workflow Rules and Validation Rules capable of running up a query count ? I see tons of those kicking off in my debugs. I didn't know if certain commands within a WF Rule or Validation Rule were capable of being regarded as a "query" call.

FURTHER TROUBLESHOOTING SOQL QUERIES COUNT BUILDUP :

16:29:59.677 (2685985805)|WF_FLOW_ACTION_DETAIL|09L5A0000000EPa|[CM Account: CM_ACCT-000153 a7d170000004EtD]|Id=09L5A0000000EPa|CurrentRule:CM_Agreement_Acct_Post_Edit3015A0000006yjd (Id=01Q5A000000iV4m)
16:29:59.677 (2686286560)|WF_FLOW_ACTION_DETAIL|Param Name: myVariable_current, Param Value: ENCODED:{![treatNullAsNull]{!ID:this}}, Evaluated Param Value: {Entity type: Service_Account__c, id: a7d170000004EtDAAU}|Param Name: myVariable_old, Param Value: {!old}, Evaluated Param Value: {Entity type: Service_Account__c, id: a7d170000004EtDAAU}
16:29:59.805 (2805328508)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|17|100
16:29:59.805 (2805507521)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|18|100
16:29:59.805 (2807466011)|LIMIT_USAGE|[EXTERNAL]|SOQL_ROWS|9|50000
16:29:59.805 (2807491103)|LIMIT_USAGE|[EXTERNAL]|SOQL|8|100
16:29:59.805 (2807499967)|LIMIT_USAGE|[EXTERNAL]|AGGS|8|300
16:29:59.805 (2851683030)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|19|100
16:29:59.805 (2851745535)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|20|100
16:29:59.805 (2860995931)|LIMIT_USAGE|[EXTERNAL]|SOQL_ROWS|10|50000
16:29:59.805 (2861038255)|LIMIT_USAGE|[EXTERNAL]|SOQL|9|100
16:29:59.805 (2861047441)|LIMIT_USAGE|[EXTERNAL]|AGGS|9|300
16:29:59.805 (2928997185)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|21|100
16:29:59.805 (2929164971)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|22|100
16:29:59.805 (2935428203)|LIMIT_USAGE|[EXTERNAL]|SOQL_ROWS|11|50000
16:29:59.805 (2935455068)|LIMIT_USAGE|[EXTERNAL]|SOQL|10|100
16:29:59.805 (2935464855)|LIMIT_USAGE|[EXTERNAL]|AGGS|10|300
16:29:59.805 (2962331811)|LIMIT_USAGE|[EXTERNAL]|DML|5|150
16:29:59.805 (2962370715)|LIMIT_USAGE|[EXTERNAL]|DML_ROWS|5|10000
16:29:59.970 (2970476238)|CODE_UNIT_STARTED|[EXTERNAL]|Validation:Service_Account:a7d170000004EtD
16:29:59.970 (2970504812)|VALIDATION_RULE|03d5A000000Jjlm|CannotHaveBothDepositAndLoanEntered
16:29:59.970 (2970609336)|VALIDATION_FORMULA|AND(ISBLANK(Account__c) = FALSE,ISBLANK(Loan_Account__c) = FALSE)|Account__c=a0J3100000MWhmM , Loan_Account__c=null
16:29:59.970 (2970618759)|VALIDATION_PASS
16:29:59.970 (2970623209)|VALIDATION_RULE|03d5A0000007vjh|RDC_Nickname_Required
16:29:59.970 (2970693403)|VALIDATION_FORMULA|AND(To_be_used_with_RDC__c = TRUE,  ISBLANK( Account_Nickname__c ) = TRUE)|Account_Nickname__c=null , To_be_used_with_RDC__c=0
16:29:59.970 (2970700220)|VALIDATION_PASS
16:29:59.970 (2970709214)|CODE_UNIT_FINISHED|Validation:Service_Account:a7d170000004EtD
16:29:59.805 (3025055647)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|23|100
16:29:59.805 (3025121258)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|24|100
16:29:59.805 (3032758764)|LIMIT_USAGE|[EXTERNAL]|SOQL_ROWS|12|50000
16:29:59.805 (3032788476)|LIMIT_USAGE|[EXTERNAL]|SOQL|11|100
16:29:59.805 (3032798893)|LIMIT_USAGE|[EXTERNAL]|AGGS|11|300
16:29:59.805 (3076818737)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|25|100
16:29:59.805 (3076882049)|LIMIT_USAGE|[EXTERNAL]|FIELDSETS_DESCRIBES|26|100
16:29:59.805 (3081120031)|LIMIT_USAGE|[EXTERNAL]|SOQL_ROWS|17|50000
16:29:59.805 (3081148655)|LIMIT_USAGE|[EXTERNAL]|SOQL|12|100
16:29:59.805 (3081158401)|LIMIT_USAGE|[EXTERNAL]|AGGS|12|300
16:29:59.805 (3116645211)|LIMIT_USAGE|[EXTERNAL]|DML|6|150
16:29:59.805 (3116678432)|LIMIT_USAGE|[EXTERNAL]|DML_ROWS|6|10000

Thank you.

4
  • 2
    I would imagine you have queries in loop somewhere which may be causing this issue. Workflow Rules or Validation Rules won't count towards query call. They are part of DML calls. E.g., if there is a Workflow field update, that's a DML operation. Validation Rules are part of a DML transaction, e.g., when you insert a record, all Validation Rules on that object are evaluated during that operation.
    – Jayant Das
    Feb 7, 2019 at 22:04
  • Another place to check would be your process builder flows. If you are looking up a record in process builder and it is running in a loop, then that would consume SOQL queries as well.
    – Aayush K
    Feb 7, 2019 at 22:28
  • Yes, I understand that - and they are indeed part of the debug log. But there isn't any SOQL "count" anywhere in which I could see what the current count is at any moment in the whole log. I'm trying to track each individual query to see what I can eliminate. I tried doing it by tracking "SOQL_EXECUTE_BEGIN" statements in the log, but that wasn't an accurate way to do it because I only counted 18 of those. So I'm trying to figure out where the other 82 are at.
    – Zoom_v
    Feb 7, 2019 at 22:31
  • And there are numbers in those statements such as "SOQL_EXECUTE_BEGIN|[189]". I thought at first that was the count for the log, but they're not in sequential order (the next could be "SOQL_EXECUTE_BEGIN|[343]" not 190). So, I'm guessing those are the "id" of the query...?
    – Zoom_v
    Feb 7, 2019 at 22:35

1 Answer 1

3

I am coming into this problem in my debug logs. But when I'm reviewing the logs I am only seeing individual reads of SOQL query counts from various apps such as...

I would like to determine what is running up the query count, but I don't see where it's building up.

Set Profiling to FINEST in your debug logs, and you will get specific queries, where they are located, and how many times they executed. In the Developer Console, go to Debug > Change Log Levels... and set your active trace flags so that Profiling is FINEST.

And I have Flows running - but I don't see a cumulative count on the SOQL query limits - just all of the sudden this

You likely have a query inside a loop or something. Without seeing the flow, it'd be kind of hard to tell, but you should be able to find it.

Also - are Workflow Rules and Validation Rules capable of running up a query count ? I see tons of those kicking off in my debugs. I didn't know if certain commands within a WF Rule or Validation Rule were capable of being regarded as a "query" call.

No, those are "for free," they do not count against CPU time, heap, DML, or query limits. Only Process Builder/Flows and Apex Code count against the limits.

7
  • Thanks Brian. I do have some loops running, but the queries used to build the collections are before the loop. One thing I am also doing is a record update for each record in the loop after second a field value. I would like to do one single update of the entire collection. But I can't get that to work in a flow - or is not possible to update all the records in an sObject collection by updating the collection instead of each record individually ? And btw - I'm not asking this as a way to reduce queries, but a way to cut down DML calls. Or at least I think that's what. Would improve.
    – Zoom_v
    Feb 8, 2019 at 4:29
  • @Zoom_v You can update a collection, I've built this before. Simply use a fast update and you're good to go.
    – sfdcfox
    Feb 8, 2019 at 4:44
  • Are you sure Val Rules or WF Rules are not capable of somehow running up a SOQL query count ? I added some of my debug to show that the count goes up and all that seems to be happening is WF or Val Rules. That section is kicked off by "CM_Agreement_Acct_Post_Edit" which is a Proc Builder - and then you can see the SOQL query count going up (8/100 ; 9/100 ; 10/100....). And it looks like the only thing that's happening is a FIELDSET (although I'm confused as to what that is doing).
    – Zoom_v
    Feb 11, 2019 at 22:05
  • @Zoom_v Process Builder does count against limits. Workflow Rules do not. It's important not to confuse the two.
    – sfdcfox
    Feb 11, 2019 at 22:11
  • Well, what is the "FIELDSETS_DESCRIBES" command which continuously appears in the debug ? It doesn't seem to be a FieldSet command. I'm trying to find one which corresponds to that. Whatever it is it looks like it's kicking off three SOQL queries each time it runs. I'm assuming it's going through a collection. Any idea what that is ?
    – Zoom_v
    Feb 12, 2019 at 2:24

You must log in to answer this question.

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