function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
James L.James L. 

SOQL returned record limit through aggregation

Hi,

 

I know there is a limit of 50,000 records for SOQL for per apex transcation.

What if an aggregation SOQL is used, and only 5 records are returned; however during aggregation on SFDC side, more than 50,000 records are involved. Will this trigger the 50,000 records limit ?

 

James

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

The SOQL limit applies to records returned, not number of rows returned from a query. So, to answer the question fully, yes, you will receive a governor exception if your query would select more than 50,000 ungrouped rows. You can also trigger non-selective query errors if you filter against large objects that are not index-filtered to less than approximately 300,000 rows.

All Answers

sfdcfoxsfdcfox

The SOQL limit applies to records returned, not number of rows returned from a query. So, to answer the question fully, yes, you will receive a governor exception if your query would select more than 50,000 ungrouped rows. You can also trigger non-selective query errors if you filter against large objects that are not index-filtered to less than approximately 300,000 rows.

This was selected as the best answer
James L.James L.

Thanks a lot