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
Aidel BruckAidel Bruck 

tracking the soql queries being called

I am working on optimizing code that I didn't originally write. 
Each object has multiple triggers, and each trigger has soql queries.
There is a trigger that is hitting the limit for soql queries. Is there an easy way to pinpoint where these queries are?
mirkimirki
Hi,

Add debug log for your user as described here:
https://help.salesforce.com/articleView?id=code_add_users_debug_log.htm&type=5

Set Database debug level to INFO in order to display all the queries. Please note that usually there is no single query that is to be blamed from hitting the limits. Usually it is the overall number of queries which is to blame. Try to reduce running the queries on same objects more than once and see if there is any impact on that.

Regards,
mirki
Raj VakatiRaj Vakati
You can use debug log in developer console.

In the bottom of page it will give you result like this
 
11:48:38.109|CUMULATIVE_LIMIT_USAGE
11:48:38.109|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 8 out of 100
  Number of query rows: 9 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 20 out of 150
  Number of DML rows: 20 out of 10000
  Number of script statements: 583 out of 200000
  Maximum heap size: 0 out of 3000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

11:48:38.109|CUMULATIVE_LIMIT_USAGE_END