I am having difficulty understanding limits on aggregate queries.

Salesforce Documentation for ReadOnly Attribute of Visualforce Page says

Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In read-only mode, this limit is relaxed to allow querying up to 1,000,000 rows.

There a Visualforce Page in ReadOnly mode, the query looks like this

SELECT SUM(Quantity) From OpporunityLineItem 
Where Product2Id.Family='Family1' 
AND OpportunityId.CloseDate > '01 01 2019'
AND OpportunityId.StageName='Closed Won'

Assuming there are 100M records and the logged in user has read access to 50M records.

What is the number of records the query will iterate to calculate sum?

Edit : This answer suggests that there are no limits on aggregate query in ReadOnly mode. SOQL aggregate query limit [Updated for Summer18]

1 Answer 1


There is a good read which we can take as reference. can salesforce handle 50 or 70 million records?

Now coming back to your question: if single org can contain this much about of data then definitely Aggregate query will process over them. But when you are processing this much amount of data, there are other limits which will affect you and the most common one is CPU time out. So you might hit that exception and not able to get expected results.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .