You need to sign in to do that
Don't have an account?

Question about "System.LimitException: Too many query rows: 50001"
I'm getting this error message:
"System.LimitException: Too many query rows: 50001", Failure Stack Trace: "(System Code) Trigger.TimeSeries: line 6, column 1"
Line 6 on Trigger.TimeSeries is not within a loop and queries an obect with only 10,000 records. So how am I exceeding 50,000 rows?
Is it possible that 50,000 refers to the sum of several different queries, but that it's just the TimeSeries query that pushes the total over 50,000?
1. Batch update of 5 records will execute the trigger once. All 5 Account records are available in a list called Trigger.new. Can you take advantage of the knowledge of the n Account.id fields known to the trigger to limit the SOQL query?
2. If the SOQL query really has > 50,000 rows returned, then you can use Batch Apex called from your trigger to do the work. This is described in detail in the apex developer's guide. You can launch it from an @future method so as to not tie up the user's response time
All Answers
Is it possible that 50,000 refers to the sum of several different queries --> this is not true..
some where in the running instance you are getting the 50,000 records in a query .... check the size of the records at line 6 once ....
Hi,
You may have other queries within the same execution and the total sum of records exceeded 50K.
Regards,
Hengky
Below is the first 7 lines of the TimeSeries Trigger, which includes the only query in the trigger.
So, if I batch update 5 Accounts, will this trigger run 5 seperate times? And if the query returns 10000+ records, would this result in cumulatively more than 50,000 records?
Is this what you mean by referring to a single "execution"?
Thank you for your help with this.
-Derek
1. Batch update of 5 records will execute the trigger once. All 5 Account records are available in a list called Trigger.new. Can you take advantage of the knowledge of the n Account.id fields known to the trigger to limit the SOQL query?
2. If the SOQL query really has > 50,000 rows returned, then you can use Batch Apex called from your trigger to do the work. This is described in detail in the apex developer's guide. You can launch it from an @future method so as to not tie up the user's response time
Thank you for everyone's help. I still don't thoroughly understand why the query was returning 50000+ rows, but I restuctured the query to pull fewer rows and it's working now. Code is below for anyone that's interested.
-Derek