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
Mani PenumarthiMani Penumarthi 

Query Limit 50000 Exceed.

Hi Guys,

I have generated a matrix format report in sandbox. But when I am trying to move that to production I am getting these Query Limit Exception.

In test class I have used seeAllData Annotation.  If though error was due to these but when I see the records in the production there is only 4000 records.




Can any one help me why I am getting these exception.
ShashForceShashForce
Hi Mani,

Can you check if you are using a SOQL query in loops? It could be an issue with improper bulkification.

Thanks,
Shashank
Mani PenumarthiMani Penumarthi
Hi Shashank,

I have not used any query inside the for loop. 

What I am trying to develop is some thing that similar to martix report as we need the three level grouping.
So I have used couple of loops one inside other using collections.

I think these may causing the error. But If you get a chance can you sugget me some alternative solution that reduce the loopings

ShashForceShashForce
Hi Mani,

If I can have a look at the whole code, I may be able to suggest something.

Thanks,
Shashank
Mani PenumarthiMani Penumarthi
Hi Shashank,

Can I send the code via an email. 

My Id is  manikumar.pnbs@gmail.com 
ShashForceShashForce
Please send it to shashank.srivatsavaya@gmail.com
ShashForceShashForce
Hi Mani,

There are quite a few SOQL queries in your class, and aggregate queries as well. In aggregate queries, for example, even if you are just saying select count(), and the count is 100, it will be counted as retrieving 100 rows, and these count against the governor limits. This could be the reason for the limit being breached.

You may have to downsize your report to a shorter date range, so that governor limits are not hit in your production.

Thanks,
Shashank
Mani PenumarthiMani Penumarthi
If that is the reason how would be the standard reports working on as it would be showing all the records when I am grouping them in two level.

Can you please let me know how standard matrix report is working on. 
ShashForceShashForce
Hi Mani,

Standard reports don't have governor limits and do not use SOQL, and hence will never hit governor limits. Governor limits and SOQL are only for the custom code that we write.

Thanks,
Shashank
Mani PenumarthiMani Penumarthi
Thanks Shashank. Thanks & Regards, Mani kumar P