0

I recollect that:

select count() from Contact

will now work for more than 50,000 rows (but can't find documentation on that improvement).

My question is whether or not there is a new (much higher) limit that applies?

1 Answer 1

2

The COUNT query is a special case of aggregate querying, as covered in the documentation:

Queries that include aggregate functions are still subject to the limit on total number of query rows. All aggregate functions other than COUNT() or COUNT(fieldname) include 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.

(My emphasis)

In that case if you only do a COUNT then it should in principle be able to count any number of rows since it is considered a single query row when it comes to contributing to limits. However, as mentioned by @David Reed, it may be that applying the query to a very large dataset will simply time out.

5
  • Yeah, that is the question: is it really unlimited?
    – Keith C
    Commented Oct 1, 2020 at 13:29
  • Do you have a lovely big table/SObject you can test this with?! :D
    – Phil W
    Commented Oct 1, 2020 at 13:29
  • Kinda tricky in that whatever row size you test, there is potentially always going to be an org with more rows in it...
    – Keith C
    Commented Oct 1, 2020 at 13:32
  • 3
    In my experience the query times out before it hits any row limits
    – David Reed
    Commented Oct 1, 2020 at 13:54
  • 1
    I've only experienced time outs in the Developer Console. Is it actually possible from Apex?
    – Adrian Larson
    Commented Oct 1, 2020 at 14:57

You must log in to answer this question.

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