To be consistent with the hard limit (currently 10,000 - double check) that we apply when we order by a grouping key, e.g.:
SELECT count(*), key FROM test GROUP BY key ORDER BY key
we should add the same hard limit when we also order by an aggregate function, since the same mechanism (priority queue) is used in both cases e.g:
SELECT count(*), key FROM test GROUP BY key ORDER BY count(*)