// 20 October 2026 · 5 min read
Bulk data operations at scale without hurting instance performance
A resumable producer/consumer engine with cursor pagination and back-off for million-record changes on busy instances.
By Acronite ServiceNow Practice
Sooner or later every mature instance needs a large data operation: retiring hundreds of thousands of stale CIs, re-classifying records after a failed migration, back-filling a new mandatory attribute, or purging years of orphaned relationships. The naive approach is a single background script that queries everything and updates it in a loop. On a busy production instance, that script will hold transactions open, contend with users and integrations, and very likely be killed by the transaction quota before it finishes. Worse, when it dies you will not know exactly how far it got.
This article describes the engine pattern we use for bulk operations at the scale of millions of records, without degrading the experience of anyone else using the platform.
The principles
Four principles drive the design:
- Small units of work. Process records in pages small enough that each page finishes in seconds.
- Resumability. Persist progress after every page so a stop, failure or deliberate pause loses nothing.
- Back-pressure. Measure the instance's health and slow down when it is busy.
- Observability. Every run produces a log you can audit: what was touched, what was skipped, and why.
Cursor pagination, not offsets
The first instinct is to paginate with offsets: records 0 to 999, then 1,000 to 1,999. This breaks the moment the operation changes the result set. If you are retiring records that match a query, each retired record drops out of the query and the offsets skip records.
We paginate by cursor instead. Order the query by a stable, indexed, unique key, typically sys_id or sys_created_on combined with sys_id as a tie-breaker. After each page, store the last key processed. The next page queries for records greater than that key. The result set can shrink or grow beneath you and the cursor still advances correctly.
query: class = X AND status = stale AND sys_id > lastCursor
order by: sys_id
limit: pageSize
process page
save lastCursor = last sys_id in page
Because the cursor is persisted, resuming is trivial: start the next run from the saved key.
Producer and consumer
For large operations we separate finding work from doing work.
The producer walks the source query by cursor and writes lightweight work items, essentially sys_ids and an operation code, into a staging table. It is fast because it only reads.
The consumers pick up batches of work items, perform the update, and mark each item done, skipped or failed with a reason. Consumers run as scheduled jobs, and we can run one or several depending on how much load the instance can take.
This split gives us several benefits:
- The total scope is known before any record changes, which makes progress reporting and sign-off straightforward.
- Failed items can be retried in isolation without re-running the whole operation.
- The staging table is the audit trail: every record touched, with outcome and timestamp.
- Work can be paused simply by disabling the consumer job.
Back-off: be a polite tenant
A bulk operation shares the instance with users, integrations and scheduled jobs. Our consumers check signals before each batch and adjust:
- Batch duration. If the last batch took longer than a threshold, halve the batch size. If it was comfortably fast, grow it gradually back towards the maximum.
- Semaphore and queue pressure. If scheduler worker queues are backing up, pause for an interval before continuing.
- Business hours. Run aggressively overnight and at weekends; throttle hard, or pause, during peak hours.
This adaptive approach means the operation runs as fast as the instance allows and no faster. Users should never notice it is happening.
Avoid the expensive side effects
Each update on a CMDB table can trigger business rules, audit history, workflow, notifications and reconciliation logic. For a single record this is fine. Multiplied by a million it is both slow and, frequently, wrong: nobody wants a million notifications.
We make deliberate decisions per operation:
- Use
setWorkflow(false)only where we have reviewed which business rules would run and confirmed none are required. This is a scalpel, not a default. - Use
autoSysFields(false)sparingly; usually you want updated-on and updated-by to reflect the change. - Prefer
updateMultiplefor simple, uniform field changes on a filtered set, which is far more efficient than looping. - Consider audit volume. Auditing a million changes may bloat the audit table; agree with the platform owner whether the staging table is a sufficient record.
Relationships first, then records
When retiring CIs, relationships matter. Deleting or retiring a CI while its relationships remain leaves dangling references that break service maps and impact analysis. Our engine handles dependents in order: relationships first, then related records such as asset links, then the CI itself. Each step is its own work item type, so partial progress is still consistent.
A real example
On one engagement, a failed model-category migration had left roughly 1.8 million stale container CIs on a large enterprise instance. Discovery kept re-creating some of them, and impact analysis was unusable. We built the engine described here: a producer that identified stale containers by class and last-discovered date, consumers that retired relationships and then CIs in adaptive batches, and a staging table that recorded every outcome. The operation ran over several days alongside normal production use without degrading instance performance, and could be paused and resumed at any point.
Testing a bulk operation
Bulk operations are code, and they need tests:
- Run the producer in dry-run mode first and review counts and samples with the data owner.
- Run consumers on a sub-production clone at full volume and time each batch size.
- Verify resumability deliberately: kill the job mid-run and confirm the next run continues from the cursor with no duplicates and no skipped records.
- Spot-check outcomes against the staging table, and keep the table until the data owner signs off.
A reusable checklist
Before a bulk operation runs in production we confirm:
- Scope is defined by query and frozen in the staging table.
- Pagination is cursor-based on an indexed key.
- Progress is persisted after every batch.
- Batch size adapts to measured duration and instance pressure.
- Side effects (business rules, notifications, audit) have been reviewed explicitly.
- Dependent records are handled before parents.
- There is a dry-run report, a rollback or restore position, and a named owner.
Built this way, a million-record operation becomes routine maintenance rather than a risky, out-of-hours event.