You need to sign in to do that
Don't have an account?
kpeterson
Query Rows Are Being Counted Wrong?
I've had "Too Many Query Rows" come up quite a few times now and i have not gotten any official response so I've made some simple cases to show the error.
I have a Full sandbox from production. If I run this query in the explorer I get a count of 8987.
I've created this test method to test my different limit issues.
The first section (the for loop) fails with "Too many query rows: 501" but it was my understanding that I should be able to process more records than the limit through the SOQL For Loop setup. Does the SOQL For Loop still count towards the Query Rows count?
The second section (the count SOQL) also throws a "Too many query rows: 501" but I'm not returning the rows.
Could someone please let me know if I'm misunderstanding the limits or let me know if this is a known issue that has a fix/is being fixed.
I have a Full sandbox from production. If I run this query in the explorer I get a count of 8987.
Code:
select count() from opportunitylineitem
I've created this test method to test my different limit issues.
Code:
public class CountTests { static testMethod void testCountTests() { Integer iCount = 0; for (OpportunityLineItem oOpportunityLineItem : [SELECT Id FROM OpportunityLineItem]) { iCount++; } system.debug(iCount); system.debug([SELECT COUNT() FROM OpportunityLineItem]); } }
The first section (the for loop) fails with "Too many query rows: 501" but it was my understanding that I should be able to process more records than the limit through the SOQL For Loop setup. Does the SOQL For Loop still count towards the Query Rows count?
The second section (the count SOQL) also throws a "Too many query rows: 501" but I'm not returning the rows.
Could someone please let me know if I'm misunderstanding the limits or let me know if this is a known issue that has a fix/is being fixed.
You are still bound to this limit when using array processing as well. The for loop structure in your test is merely a convenience. In a context where the soql row limit is higher than the max array size - such as webservice methods or visualforce page controller classes/extensions - this array processing will allow you to overcome the 1000 max collection size limit by chunking:
Message Edited by mtbclimber on 02-24-2008 10:13 AM
I didn't understand. How do I get a count of how many rows are in a table if there
are more than 8k?
Thanks,
Mike
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