Activity Forums Salesforce® Discussions Limit of aggregate query in salesforce.

  • madhulika shah

    Member
    September 12, 2018 at 6:06 am

    Hi Prachi,

    I think that the issue here is that an aggregate query is considered to have accessed every record included in the aggregation. Thus the 50000 row limit isn't the number of records returned by the query, its the number of records 'touched'. As you have a clause of 'LIMIT 50000', you are asking for a maximum of 50000 aggregates to be returned by the query and if any of these "touches" more than one record, you will exceed the limit.

    Thanks.

  • Avnish Yadav

    Member
    September 12, 2018 at 9:13 am

    Hello,

    Queries that include aggregate functions are still subject to the limit on total number of query rows i.e 50,000. All aggregate functions other than COUNT() or COUNT(fieldnameinclude each row used by the aggregation as a query row for the purposes of limit tracking.

    For COUNT() or COUNT(fieldname) queries, limits are counted as one query row, unless the query contains a GROUP BY clause, in which case one query row per grouping is consumed.

    Thnaks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos