Understanding Apex Cursors in Salesforce — And an Unexpected Limit We Hit in Production

Apex Cursors are a powerful new Salesforce feature designed to help developers work with large datasets more efficiently. Introduced in Summer ’24 and currently still in beta, they allow you to process large SOQL query results in smaller, controlled chunks—all within a single transaction. This makes them especially compelling for use cases like pagination, where traditional SOQL queries are limited to offsetting through only the first 2,000 rows.

If you’re exploring this new capability, Salesforce’s documentation provides a deeper look into how Apex Cursors work and how they’re intended to be used.

The DailyApexCursorRowsLimit — What We Know

One important quota associated with Apex Cursors is the DailyApexCursorRowsLimit, which represents the total number of rows fetched through Apex Cursors in a 24-hour period. The limit is 100 million rows, according to Salesforce’s documentation.

Curiously, despite being documented, this limit is not currently surfaced in the Limits class, which makes it challenging to monitor programmatically.

Our Experience: Hitting the Limit With Minimal Data

In our production environment, we unexpectedly ran into this cursor limit—despite:

  • Having very few active users
  • Working with custom objects containing only ~200k rows
  • Running highly selective queries supported by indexes
  • Observing in debug logs that each query was returning only 50–60 rows

Based on our data volume and query patterns, reaching 100 million cursor rows in a day should have been virtually impossible. Yet the limit was triggered.

Salesforce Support’s Response

We opened a premium support ticket with Salesforce to understand what might have caused this. At the time of writing, Salesforce support has not been able to explain why the limit was hit, given the low data volume and small result sizes.

Closing Thoughts

Apex Cursors are an exciting addition to the Salesforce platform, but as with many beta features, there are still some rough edges. The unexpected behavior around the DailyApexCursorRowsLimit—and the difficulty in diagnosing it—highlights the need for clearer tooling and visibility around this limit.

If you’re planning to adopt Apex Cursors in production, especially at scale, keep a close eye on usage patterns and consider implementing fallback mechanisms until the feature matures.

Leave a comment