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

SOQL Count() query causes "Too many query rows: 501" error?
I've deployed all my triggers and classes to a full sandbox (structure and data) without any problems. All my tests create their own test objects/data so it doesn't rely on instance data. This one in particular uses two hardcoded users that exists in all instances but since I'm creating the test accounts any existing data should not interfere with the queries.
Yet when I try to deploy to our production instance I get a "too many query rows: 501" error on this line:
Is this error saying that too many rows are being returned? The documentation says that 1,000 is the max number of records that can be retrieved through a query but it's flagging it on 501 and this is a COUNT() query so it shouldn't matter.
Message Edited by kpeterson on 12-12-2007 06:30 AM
Yet when I try to deploy to our production instance I get a "too many query rows: 501" error on this line:
Code:
System.assertEquals(60, [SELECT COUNT() FROM SFDC_Assignment__c WHERE Account__c IN :oAccounts AND OwnerId = :oOriginalUser.Id AND Resource__c = :oOriginalUserResource.Id]);
Is this error saying that too many rows are being returned? The documentation says that 1,000 is the max number of records that can be retrieved through a query but it's flagging it on 501 and this is a COUNT() query so it shouldn't matter.
Message Edited by kpeterson on 12-12-2007 06:30 AM
All Answers
This can't be a limit of count() because it can return much larger numbers.
The key to get this error fixed is ISOLATION of your test data from the org's data. Try executing your test via System.runAs(<User>). I am sure it will help.
This blog post explains this in more detail : http://www.tgerm.com/2010/05/systemrunas-501-apex-query-rows.html