[SalesForce] Developer Console can SELECT or COUNT() more than 50.000 records. Why not Apex

For years people were looking for ways to query more than 50.000 records in Salesforce without running into Too many query rows: 50001. Event doing a COUNT() query was impossible.

By accident, I just did a query on a type with more than 1 million records. In the Query Editor of the Dev Console. And it worked!

When I tried the same in Apex it failed as expected. Why?

Best Answer

Apex uses more resources than a simple API call, such as extra memory, CPU time, etc, so there's additional limits in place. The Developer Console, contrariwise, uses the API, which is just a server-side database cursor. As such, you can technically query up to 50,000,000 rows in the Developer Console (though very large queries may time out or freeze your browser).

Related Topic