Concept 6 of 8Data at scale

Big objects

Storing billions of records inside Salesforce: custom big objects with a defined index, how to write and query them, their restrictions, and where they fit against archiving products and external storage.

Your confidence:Not rated

Simple explanation

Big objects store very large volumes of data inside Salesforce with consistent performance, designed for data you write once and read by key: history, audit trails, event logs, archived records.

  • Standard big objects are used by Salesforce features, for example FieldHistoryArchive for Field Audit Trail.
  • Custom big objects (__b) are defined in metadata with fields and an index (a composite primary key of up to 5 fields, defined at creation and unchangeable) βš‘ verify field count.

Writing: Database.insertImmediate(records) in Apex, the APIs (including Bulk), or Data Loader. Inserting a record with the same index values overwrites it (idempotent upsert behaviour).

Reading: SOQL must filter on the index fields in order, starting from the first, using equality on leading fields and at most one range on the last filtered field. No arbitrary filters, no aggregates beyond what's supported.

Restrictions: no triggers, flows or validation rules; no sharing rules (access through object and field permissions); limited UI (custom LWC needed to display); not in standard reports.

Real-world analogy

A big object is a library's closed archive. It holds millions of documents cheaply, but you can only request a document by its catalogue number (the index), in the catalogue's order. You can't browse the shelves or ask "show me everything about shipping".

Worked example

Archiving closed cases older than three years into a custom big object, keyed by account and close date:

// Index (defined at creation, in this order): Account_Id__c, Closed_Date__c, Case_Number__c
List<Case_Archive__b> archive = new List<Case_Archive__b>();
for (Case c : casesToArchive) {
    archive.add(new Case_Archive__b(
        Account_Id__c = c.AccountId,
        Closed_Date__c = c.ClosedDate,
        Case_Number__c = c.CaseNumber,
        Subject__c = c.Subject,
        Resolution__c = c.Resolution__c
    ));
}
Database.insertImmediate(archive);   // not part of the transaction's rollback
// Query: leading index field with equality, then a range on the next one
List<Case_Archive__b> history = [
    SELECT Case_Number__c, Closed_Date__c, Subject__c
    FROM Case_Archive__b
    WHERE Account_Id__c = :accountId AND Closed_Date__c > :fiveYearsAgo
];

Diagram

Rendering diagram…

Key points

  • Billions of records inside Salesforce for write-once, read-by-key data.
  • Index = composite key defined at creation, can't change; queries follow it in order.
  • Database.insertImmediate; same key overwrites (idempotent).
  • No triggers, flows, sharing rules or standard reports; custom UI to display.
  • Typical uses: archive, audit, history, logs.
  • Compare with Salesforce Archive (managed product) and external storage before building.

Limits and gotchas

  • Design the index first; it decides every query you'll ever run. Changing it means a new big object and a migration.
  • insertImmediate isn't rolled back with the surrounding transaction, so archive-then-delete flows need a verification step before deleting the source.
  • Async SOQL for big objects has been retired; use standard SOQL on the index or Bulk API queries βš‘ verify current status.
  • Capacity: a free allocation of big object records per org, with more purchasable βš‘ verify.

🎀 How to say this in an interview

Big objects come up in archiving and LDV questions. Show that you know the index constraint, the lack of automation and sharing, and that you'd compare them with the Salesforce Archive product and off-platform storage based on access needs.

Common follow-ups

Why not just keep closed cases in the Case object?

Volume hurts query performance, reports, sharing recalculation and storage cost. Moving old, rarely accessed records to an archive keeps the operational object lean while retaining the data for compliance.

Big object, Salesforce Archive or external storage: how do you choose?

Big objects if you need the data inside Salesforce with key-based access and are prepared to build the UI. Salesforce Archive for a managed, policy-driven archive with search and restore. External storage (warehouse, data lake) when analytics or very cheap retention matter more than in-app access.