+ Start a Discussion
JWykelJWykel 

GROUP BY / ROLLUP Query Rows

Why does using GROUP BY ROLLUP multiply the number of query rows returned by the number of fields you are rolling up + 1?

Example: I have 3408 records in the database. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY Sex__c, IsLow__c]
I get the number of query rows as 3408. If I run:
[SELECT Sex__c, IsLow__c, COUNT(Id) FROM MyObject__c GROUP BY ROLLUP(Sex__c, IsLow__c)]
I get the number of query rows as 10224.

It seems that the ROLLUP is 'touching' each record for each grouping field and then again for a total.
Is this the case? If so, how can I get around it when I have to run the query on larger data sets?
Is this documented anywhere?
Niket SFNiket SF
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_groupby_rollup.htm
JWykelJWykel
Niket SF, thank you for pointing to that; I have read and re-read it already and it does not say anywhere that using ROLLUP will cause a multiplication of the number of query rows used.