All articles

Data 360

Apex cursors on Data 360 objects: what the Winter '27 beta costs

Winter '27 lets an Apex cursor page through a Data 360 Data Model Object without Batch Apex, forward or backward. The throughput is real. So is the part people skim: every one of those queries meters Data Services credits, and the cursor expires in 24 hours. Here is the mechanism, the cost, and when to reach for it over the paths you already have.

For years, pulling a large Data 360 object into Apex and processing it meant one thing: a Batch Apex class.

You could run SOQL against a Data Model Object from Apex since API 61.0, but anything big meant a Database.QueryLocator, the five-concurrent-batch-jobs ceiling, and a start-execute-finish dance for what you wished was a loop.

Winter ‘27 adds a cleaner primitive. An Apex cursor now opens over a Data 360 DMO, and you fetch a slice of the result set at a time from a chain of Queueable jobs instead of a batch.

The move I would make is to use the cursor for the large sweep that a Queueable can drain, and to watch the credit meter while you do it. Reading a DMO from Apex draws Data Services credits from your Data 360 subscription, and the cursor is a 24-hour object, not a permanent handle.

The throughput is a real gain. The cost is a real line item you now own.

I will take what the beta is, the credit behaviour that decides whether it belongs in your code, a Queueable that drains one cleanly, and how it stacks up against the paths you already use.

What Winter ‘27 added, exactly

Apex cursors are not new. Database.getCursor() has let you break a SOQL result into fetchable pieces, processed across a chain of asynchronous transactions, as an alternative to Batch Apex. A cursor holds up to 50 million rows, you read them with Cursor.fetch(position, count), and Cursor.getNumRecords() tells you how many are waiting.

Winter ‘27, API version 68.0, extends that primitive to Data 360. The Apex Cursors guide now carries a section titled “Use Apex Cursors with Data 360 Data Model Objects (Beta)”. The Winter ‘27 developer guide puts it plainly: cursors work with DMOs, and you fetch any slice of a large result set, forward or backward, without Batch Apex.

The feature landed as a beta the week of August 31, 2026. Governed by the Beta Services Terms, keep it off any production critical path for now.

The shape is the one you already know. You open a cursor over a SOQL query against a DMO, then fetch in chunks:

// Open a cursor over a Data 360 DMO (Beta, API 68.0+).
Database.Cursor cur = Database.getCursor(
    'SELECT Id__c, LastModifiedDate__c FROM Individual__dlm ORDER BY Id__c'
);
Integer total = cur.getNumRecords();
System.debug('Rows waiting: ' + total);

// Fetch the first 200 rows; fetch(position, count) reads any slice.
List<SObject> firstPage = cur.fetch(0, 200);

One detail to internalise before anything else: a cursor over a DMO expires 24 hours after you create it. Try to fetch from it after that and you get a System.InvalidQueryLocatorException.

A standard SOQL cursor does not carry that documented create-to-expire clock. So if you have used cursors before, this is the new rule to design around.

The credit meter is the part people skim

Here is the behaviour that decides whether the cursor belongs in your code at all, and it is not a cursor feature. Running SOQL against a DMO from Apex can consume Data Services credits from your Data 360 subscription. That is true of a QueryLocator, a SOQL for loop, and a cursor alike. The cursor just makes it easier to sweep a lot of rows, which makes it easier to spend.

Treat a DMO cursor the way you treat a metered callout. In billing terms it is closer to one than to a free SOQL against a standard object.

A nightly Queueable chain that drains a few million rows is a recurring credit draw, and it sits unnoticed in your consumption until someone reads the invoice. The Data 360 credit-optimization playbook pushes the same discipline everywhere: attribute the spend to the job that causes it before you scale the job.

Salesforce gives you the counters to do that. Winter ‘27 adds Limits.getDataCloudCursors() and Limits.getDataCloudCursorRows(), so your code can read how many Data 360 cursors and cursor rows the transaction has used, the way you already log SOQL and DML with the rest of the Limits methods. Instrument those from the first line of the Queueable, not after the first surprising bill.

System.debug('DC cursors used: ' + Limits.getDataCloudCursors());
System.debug('DC cursor rows:  ' + Limits.getDataCloudCursorRows());

A Queueable that drains one cleanly

The pattern the beta is built for is a Queueable that opens the cursor, processes a page, and re-enqueues itself with the next position until the rows run out. Storing the cursor and the position as instance fields keeps the state across the chain.

public class DmoCursorDrain implements Queueable {
    private Database.Cursor cur;
    private Integer position;
    private static final Integer PAGE = 200;

    // First run opens the cursor; later runs resume from a saved position.
    public DmoCursorDrain() {
        this.cur = Database.getCursor(
            'SELECT Id__c, SourceRecordId__c FROM Individual__dlm ORDER BY Id__c'
        );
        this.position = 0;
    }
    public DmoCursorDrain(Database.Cursor cur, Integer position) {
        this.cur = cur;
        this.position = position;
    }

    public void execute(QueueableContext ctx) {
        Integer total = cur.getNumRecords();
        if (position >= total) return; // drained

        Integer count = Math.min(PAGE, total - position);
        List<SObject> page = cur.fetch(position, count);

        process(page); // your work: transform, write to a custom object, call out

        Integer next = position + count;
        if (next < total) {
            // Re-enqueue before the 24-hour expiry closes the cursor.
            System.enqueueJob(new DmoCursorDrain(cur, next));
        }
    }

    private void process(List<SObject> rows) {
        // keep heap in check: hold one page, not the whole set
    }
}

Two things keep that code safe. Re-enqueue well inside the 24-hour window, because a chain that stalls overnight resumes against an expired cursor and throws.

And hold one page in memory, not the accumulated set. The Winter ‘27 heap increase gives async transactions more room, but a cursor exists so you never hold 50 million rows at once, and leaning on it that way is the point.

How it stacks against the paths you already have

The cursor is not the only way to read a DMO from Apex, and it is not always the right one. You have three other options, and the choice is about shape, not fashion.

A plain SOQL for loop over a DMO is the simplest thing that works. For a result set that fits inside one synchronous transaction, it is what you should write. It needs API 61.0 or later; below that, a DMO query returns only the first 201 rows, which is a silent trap on an old-API class. Reach for a cursor when the set is too large for one transaction and you want to spread it across a Queueable chain without the five-job batch ceiling.

The Data 360 Query API V2 is the off-platform path. It pages with a forward-only nextBatchId and a done flag, and it expects you to fetch the whole result inside an hour. Use it from an external service that is already calling your org over REST. The in-Apex cursor is for logic that has to live on-platform, in an action or a scheduled job.

Then there is the sfsqlquery namespace, which Salesforce recommends for new Data 360 work and which runs SQL, not SOQL, against a data space through SqlStatement and a SqlQueueable you subclass.

The namespace and the cursor solve overlapping problems from different ends. sfsqlquery is the richer SQL surface over a data space; the cursor is SOQL over a DMO with the familiar fetch ergonomics. If your query is really SQL, reach for the namespace. If it is SOQL and you want cursor semantics inside a Queueable, the cursor is the shorter path.

The gotchas that will bite

A few rules carry over from DMO-in-Apex generally, and they catch people who treat a DMO like a local object.

A SOQL query against Data 360 behaves like a callout. You cannot run it after uncommitted DML in the same transaction, or you get an UnexpectedException. Commit or roll back first, the same ordering constraint any HTTP callout after DML imposes.

DMOs are reachable from Apex in system mode even without an assigned permission set, so field- and record-level access is yours to enforce in code. The platform will not stop a cursor from reading a field the running user should never see.

The ordinary cursor limits still apply: up to 100 fetch calls per transaction, each counting against your SOQL query and row limits, and a cap on how many cursors an org opens in a rolling 24 hours. A Queueable chain that fetches once per transaction stays well clear of the per-transaction ceiling, which is another reason the one-page-per-execute pattern above is the safe default.

What I would do this release

Treat the DMO cursor as a throughput tool with a meter attached, and gate it accordingly. If a SOQL for loop drains your result in one transaction, keep writing that.

When the set is genuinely large and belongs on-platform, open a cursor inside a Queueable, fetch one page per execute, re-enqueue inside the 24-hour window, and log Limits.getDataCloudCursors() and Limits.getDataCloudCursorRows() so the credit draw is a number you can see from day one.

Because the feature is beta, prove the whole chain in a sandbox against a representative DMO before anything production depends on it, and read the credit it drew against what the job is worth.

The cursor removes a real piece of friction that pushed teams into Batch Apex they did not want. It does not remove the bill, and the teams that stay happy with it are the ones who watched the meter from the first run.

Understanding the basics

What are Apex cursors for Data 360 objects?

They are a Winter ‘27 (API 68.0) beta that lets a Database.getCursor() cursor run over a SOQL query against a Data 360 Data Model Object. You fetch rows in slices with Cursor.fetch(position, count), forward or backward, typically across a chain of Queueable jobs, which lets you process a large DMO result set without Batch Apex. It is governed by the Beta Services Terms, so keep it off production critical paths until it reaches general availability.

Do Apex queries against Data 360 DMOs cost credits?

Yes. Running SOQL against a DMO from Apex can consume Data Services credits from your Data 360 subscription, and that applies to query locators, SOQL for loops, and cursors alike. The cursor is not what introduced the cost, it just makes a large sweep easier. Monitor the draw in code with Limits.getDataCloudCursors() and Limits.getDataCloudCursorRows(), and attribute the spend to the job that causes it before you scale that job.

How long does a Data 360 Apex cursor last?

A cursor over a DMO expires 24 hours after you create it. If you try to fetch from it after that, Apex throws a System.InvalidQueryLocatorException. When you drain a cursor across a Queueable chain, re-enqueue each link well inside that window so a stalled job does not resume against an expired cursor.

When should I use a cursor instead of the Query API or sfsqlquery?

Use a plain SOQL for loop when the result fits in one transaction. Use an in-Apex cursor when the set is large, the logic must stay on-platform, and you want to spread it across Queueables without the five-job batch ceiling. Use the Query API V2 from an external caller paging over REST, and the sfsqlquery namespace when your query is really SQL against a data space rather than SOQL against a DMO.


Reading a Data 360 bill that outran its forecast, or deciding how a large DMO should feed an Apex action without the credit draw surprising you? Getting the data foundation both trustworthy and affordable is the work our integration and Data Cloud team does. Talk to us.

Keep reading

All articles