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
PallavPallav 

Too many SOQL queries but in the Debug Log it shows only Number of SOQL queries: 3 out of 20 excuted

Hi All,

I am facing a very unusual situation in the Production instace. I have developed a trigger to populate some fields, it works absolutely fine in the sandbox instance. When I have moved the trigger to the production instance with 90% of code coverage. it is giving me the "Too many SOQL queries" exception when data loaded in bulk. But, in the Debug Log it shows only Number of SOQL queries: 3 out of 20 excuted. I am totally confused what is going on and have no idea what so ever why this is happening.

This is the line that is causing the error:

Map<Id, User> userRecords =  new Map<Id, User>([Select Id, UserType from User where Id In : OwnerIds])

Here, "OwnerIds" is a list of Ids, which was got by:-

List<Id> OwnerIds = new List<Id>();
for (Integer i = 0; i < Trigger.new.size(); i++)
{
        OwnerIds.add(trigger.new[i].OwnerId);
}


I would request you to kindly through some light on the situation that I am in. Hoping for a quick response from your side.

Also, thanks in anticipation of your answers.

Thanks and regards
Pallav
TehNrdTehNrd
What is your batch size? Also, are there any other cascading triggers that are executed when this one is executed?

For example if you have a trigger on Opportunity that has 4 SOQL queries that updates an account and the Account has a trigger with 4 SOQL queries I believe your total is  applied to your limit is 8 where if you just look at the debug log on one trigger it would only show 4.


Message Edited by TehNrd on 05-07-2008 01:12 PM