1

I get error

"AccountTriggerBefore: System.LimitException: Too many query rows: 50001",

when attempting to change owner on account object via Apex Dataloader. There are 131 records that I am trying to update. Any ideas what does this mean and how to resolve this

3
  • 1
    There are too many queries. Probably because you run queries or dml operations in a loop. Post your code if you want a full answer
    – Novarg
    Nov 25, 2014 at 9:54
  • 1
    Check if you have any Triggers on Account object and check for SOQL queries inside them
    – highfive
    Nov 25, 2014 at 10:04
  • 1
    @Novarg please read error messages carefully, your comment doesn't apply to this problem. As highfive stated the problem is likely a SOQL query that has no where clause or having a where clause that is not specific enough. Nov 25, 2014 at 10:26

2 Answers 2

1

The SOQL query used in the trigger AccountTriggerBefore is returning more than 50K records. Please use LIMIT and provide more filtering criteria in the SOQL query to reduce the number of records getting returned.

-1

This is occuring because of most important Governor limit .You have to bulkify your trigger which was being fired on the above mentioned event.

Up to 200 records can enter your trigger at once! Remember Trigger.new? Salesforce will batch up mass updates and include up to 200 records at once in it (this commonly happens when using tools like Data Loader). So for example, if you do one SOQL query per record, you’re going to go over the 100 SOQL query limit! Triggers are on the same shared Governor Limit! Got ten triggers that run when an Account is updated? Each trigger does not get its own set of limits! One limit per update, no matter how many triggers are run! This means that if each of your ten triggers runs 12 SOQL queries, you will run a total of 120 SOQL queries and go over the 100 SOQL query limit! This means you need to be extra conservative!

2
  • What makes it the "most important Governor limit"?
    – Adrian Larson
    Jan 31, 2015 at 17:20
  • If you read OP's question, they are not violating SOQL Query limit, they are violating DMLRows.
    – Adrian Larson
    Jan 31, 2015 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .