You need to sign in to do that
Don't have an account?
Joel CHADET
How to work with more than 50000 rows
Hi,
In the controller class of a lightning component, I have this following group by query :
In developer console it returns 33 rows.
When i try to run my component i have this error message :
FATAL_ERROR System.LimitException: Too many query rows: 50001
Number of SOQL queries: 1 out of 100
number of query rows: 139180 out of 50000 *******
My query cannot be more filtered, my component use Chart.js to display Chart, so all the 139180 rows are needed.
Any suggestion ?
In the controller class of a lightning component, I have this following group by query :
SELECT CALENDAR_YEAR(Transaction_Date__c) year,CALENDAR_MONTH(Transaction_Date__c) gbfield, SUM(Net_Net_Sales_EUR__c) amount FROM Sales_Reporting__c WHERE Transaction_Date__c IN (LAST_N_FISCAL_YEARS:1,THIS_FISCAL_YEAR) AND Sold_To__r.Country__r.Id ='a4O0L000000QJsKUAW' group by CALENDAR_YEAR(Transaction_Date__c),CALENDAR_MONTH(Transaction_Date__c) ORDER BY CALENDAR_MONTH(Transaction_Date__c)
In developer console it returns 33 rows.
When i try to run my component i have this error message :
FATAL_ERROR System.LimitException: Too many query rows: 50001
Number of SOQL queries: 1 out of 100
number of query rows: 139180 out of 50000 *******
My query cannot be more filtered, my component use Chart.js to display Chart, so all the 139180 rows are needed.
Any suggestion ?
Hi Joel, in order to bypass the soql row limit from Apex, you'll need to execute your query through the rest api. Then process the result within your class. Here is an example :
as you are running your code in lightning , you'll face a new issue related to the lightning session that will not let you call a rest Api service.
follow the blog below to solve this new issue :
https://sfdcpanther.wordpress.com/2018/02/05/how-to-call-salesforce-api-from-lightning-component/
I hope it will help you
Fabrice
All Answers
Here is the apex class, the query executed is in my first post.
Hi Joel, in order to bypass the soql row limit from Apex, you'll need to execute your query through the rest api. Then process the result within your class. Here is an example :
as you are running your code in lightning , you'll face a new issue related to the lightning session that will not let you call a rest Api service.
follow the blog below to solve this new issue :
https://sfdcpanther.wordpress.com/2018/02/05/how-to-call-salesforce-api-from-lightning-component/
I hope it will help you
Fabrice
I am hitting Heap Size Limit Exceptions when I try to aggregate the records.
Fabrice
Sorry for the confusion but I'm not using an aggregate query its a child to parent query. Yes, it's fine at dev console. And works with workbench.
I am having a problem when I try to get the multiple batches of 2000 records into one list variable.
I am getting a heap size limit exception using multiple requests below.
It is understandable as my actual query gets 10 fields, but have not yet found a way on how to resolve/work around it.
Sorry , I was a bit busy. Could you figure out where the heapSize exception is happening ?
I mean, does it happen on line 12 (therefore you could not see the system.debug)
Or is it happening after.
If the issue is happening before line 12 , you 'll have to split your query in many so that you don't hit the limit.
If it's happening after line 12,
you'll need to make your own garbage collector. This mean that you'll have to remove from memory the record when you don't need them in order to gain some memory
Could you share the code you are trying ? The one provided is not compiling