I'm repeatedly getting following known exception:
Too many query rows: 50001
An unexpected error has occurred. Your development organization has been notified.
The thing here is that my query is retrieving only 18 rows, so my jaw fall to the floor instantly.
This is my query:
SELECT Date__c, Country__c FROM Insight2__c GROUP BY Date__c, Country__c ORDER BY Date__c ASC
This are the log main lines, check the 2nd line to verify there is only 18 rows retrieved:
16:24:46.0 (110288675)|SOQL_EXECUTE_BEGIN|[6]|Aggregations:0|SELECT Date__c, Country__c FROM Insight2__c GROUP BY Date__c, Country__c ORDER BY Date__c ASC NULLS FIRST
16:24:46.0 (380090845)|SOQL_EXECUTE_END|[6]|Rows:18
16:24:46.0 (380142615)|EXCEPTION_THROWN|[6]|System.LimitException: Too many query rows: 50001
16:24:46.0 (380413663)|HEAP_ALLOCATE|[6]|Bytes:30
This is the screenshot of the developer console query editor with the exact same query and the above mentioned 18 rows:
This is my code:
public static List<DateInfo> GetStruct() {
Map<String, DateInfo> temp = new Map<String, DateInfo>();
List<AggregateResult> insights = [ SELECT
Date__c,
Country__c
FROM Insight2__c
GROUP BY
Date__c,
Country__c
ORDER BY Date__c];
for(AggregateResult inv: insights){
Date d = (Date)inv.get('Date__c');
String country = (String)inv.get('Country__c');
if(temp.get(country) == null) {
Set<String> months = new Set<String>();
months = GetPeriodsByDate(d, months);
DateInfo dInfo = new DateInfo(country);
dInfo.Add(d.year(), months);
temp.put(country, dInfo);
}
else {
DateInfo dInfo = temp.get(country);
Set<String> months = dInfo.GetInfo(d.year());
if(months == null)
months = new Set<String>();
months = GetPeriodsByDate(d, months);
dInfo.Add(d.year(), months);
}
}
return temp.values();
}
Thanks in advance!