Blog

Big Objects in Salesforce

Time to think bigger with Big Objects in Salesforce! These allow you to handle massive volumes of data efficiently, making them ideal for long-term data storage and archiving.

What Are Big Objects in Salesforce?

  1. Big objects allow you to store and manage a massive amount of data on the Salesforce platform.
  2. Big objects provide consistent performance for a billion records or more, and are accessible with a standard set of APIs to your org or external system.

A big object provides consistent performance, whether you have 1 million records, 100 million, or even 1 billion.

Salesforce has two flavours of big objects.

  1. Standard Big Object
  2. Custom Big Object

Index in big object :

  • The index defines the composite primary key for a custom big object and is used for querying and filtering the big object data.
  • The fields defined in your index should be the fields that will be most relevant to your queries.
  • Assign the field you will use most frequently in a query filter to the first position in your index.
  • You can also use only specific comparison operators, depending on the field’s position in your query.

Note : If you’re using SOQL to query your big object, you can query only on the fields that make up your index, in the order you defined them in.

Things to keep in mind when using big objects :

Big objects support only object and field permissions.

Index in big object :

  • The index defines the composite primary key for a custom big object and is used for querying and filtering the big object data.
  • The fields defined in your index should be the fields that will be most relevant to your queries.
  • Assign the field you will use most frequently in a query filter to the first position in your index.
  • You can also use only specific comparison operators, depending on the field’s position in your query.

Things to keep in mind when using big objects :

  • Big objects support only object and field permissions.
  • Once you’ve deployed a big object, you can’t edit or delete the index. To change the index, start over with a new big object.
  • SOQL relationship queries are based on a lookup field from a big object to a standard or custom object in the select field list (not in filters or subqueries).
  • Big objects support custom Salesforce Lightning and Visualforce components rather than standard UI elements (home pages, detail pages, list views, and so on).
  • You can create up to 100 big objects per org.
  • Big objects don’t support transactions that include big objects, standard objects, and custom objects.
  • To support the scale of data in a big object, you can’t use triggers, flows, processes, and the Salesforce app.

Note : While custom big objects are similar to standard and custom objects, some parameters are unique to big objects, and some parameters don’t apply.

Objects Vs Big Objects

  Object Big Object
Create Manual and Metadata Metadata
Api Name __c __b
Track Activity Yes No Option
Field History Tracking Yes No Option
Data Type All Text,Date/Time,Lookup,E
mail,Number,Phone,Text Area (Long),URL
Edit Field Yes Yes
Delete Field Yes No
Trigger Yes No
Report Yes No
Storage It Count Against Storage It doesn’t count against Storage.

Let’s create a big object!

1. Click settings icon and select Setup.

2. Enter Big Objects in the Quick Find box, then select Big Objects

3. Create a big object and add some basic details.

Overview of Big Objects in Salesforce

4. Add custom fields. They store the data on your big object.

Big Objects in Salesforce Architecture Diagram

5. Add an index. The index defines the composite primary key for a big object and is used for querying and filtering the big object data.

Use Cases of Big Objects in Salesforce

6. Save the big object and change the status to Deployed.

Ways to create a big object records

  • CSV file with Data Loader or the API.
  • Do it entirely through Apex.

Populate a Custom Big Object with Apex

  • You can create and update custom big object records in Apex using the insertImmediate method.

Example :

Here Consider an insert operation in Apex that assumes a table in which the index consists of FirstName__c, LastName__c, and Address__c.

// Define the record.
TestRecord__b tr = new TestRecord__b();
tr.FirstName__c = ‘John’;
tr.LastName__c = ‘Smith’;
tr.Address__c = ‘1 Market St’;
tr.PhoneNumber__c = ‘555-1212’;
database.insertImmediate(tr);
// A single record will be created in the big object.

// Define the record with the same index values but different phone numbers.
TestRecord__b tr = new TestRecord__b();
tr.FirstName__c = ‘John’;
tr.LastName__c = ‘Smith’;
tr.Address__c = ‘1 Market St’;
tr.PhoneNumber__c = ‘555-1212-123’;
database.insertImmediate(tr);
// The existing records will be “re-inserted”. Only a single record will remain in the big object.
// Define the record with the different index values and different phone number
TestRecord__b tr = new TestRecord__b();
tr.FirstName__c = ‘John’;
tr.LastName__c = ‘Smith’;
tr.Address__c = ‘Salesforce Tower’;
tr.PhoneNumber__c = ‘415-555-1212’;
database.insertImmediate(tr);
// A new record will be created leaving two records in the big object.

Delete data in big object

  • The Apex method deleteImmediate() deletes data in a custom big object.
  • Declare an sObject that contains all the fields in the custom big object’s index.
  • The sObject acts like a template. All rows that match the sObject’s fields and values are deleted.
  • You can specify only fields that are part of the big object’s index. You must specify all fields in the index.
  • You can’t include a partially specified index or non-indexed field, and wildcards aren’t supported.

// Declare sObject using the index of the custom big object


List tr = new List();
tr.addAll([SELECT FirstName__c, LastName__c, Address__c FROM
TestRecord__b]);

Database.deleteImmediate(tr);

Note : The batch limit for big objects using deleteImmediate() is 50,000 records at a time.

We are Inno Valley Works, We are a passionate team of developers, best thinkers and consultants who can solve anything and everything.
With our highly engaging team, you can easily bring the vision to all your business ventures come true.
We have team, put your problem, get your solution

 

🎥 Check Out Our YouTube Channel

Explore helpful tutorials, product updates, and feature walkthroughs from the team at Innovalley Works.

👉 Visit Our Channel