+ Start a Discussion
sindhugsindhug 

In our production getting System.LimitException: marssfs:Too many query rows: 50001 exception.what is the reason ?

when i write a query with limit 49997.it shows the Number of query rows: 119997 out of 50000 ******* CLOSE TO LIMIT.
I want to know how it works.
 
VJ_SFDCVJ_SFDC
Did you go through the salesforce governor limits,  Since you are querying 49997 records so you have to see 49997 out of 50000 ****** Close to Limit.  Not sure how you could see 119997 out of 50000 ******* CLOSE TO LIMIT.

There is a limit and max you can query 50000 records with soql query.

Refer this link.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm

 
Edgars Everts 5Edgars Everts 5
Hi, sindhug!

Just wonder if you wrote single SOQL query, or there was many SOQL in single transaction. Transaction =? sinlge operation even it consist of more than one step, and each step might have their own SOQL. I guess that 50000 limit counts against the transaction.
Since that even you limit your SOQL to 50000, it would throw an errror message.
Do you use SOQL with limit:
SELECT id, name, etc FROM object LIMIT 49997

Could it be that Your code get more 70000 rows in SOQL queries? 

Kind regards
 
David @ ConfigeroDavid @ Configero
The maximum record query limit counts all SOQL queries within that transaction.  If one is returnng 49,997 and other SOQL queries are running returning more... well you see how fast they add up (pun intended ;)