Introduction
Big object is the object in which we can store up to one billion records. We can archive large amount of historical data in Salesforce.
When to use Big Object:
- If you have the large amount of data to be archived for the historical data
- Performing the analysis of live and historical data.
- Tracking an event with the help of event monitoring.
Types of big Objects:
- Standard big objects (FieldHistoryArchive): It stores large amount of data as part of Field Audit Trail.
- Custom big objects: It will be created by appending api name with ‘__b’.
Consideration
- Big object cannot be created through the UI. It can be created via Metadata API.
- Big Object supports Visualforce page and Lightning components.
- Once a big object is deployed to Salesforce, we can change some of the attributes like label name, API name, etc. We cannot change the datatype.
- Big Object does not support sharing rules, trigger, flows, processes, and Salesforce Apps.
- We can create up to 100 big objects per org. Field limits is like custom object field limitation.
- We can check the storage status by Setup > Data Management > Storage Usage.
- Big data cannot be accessed from Salesforce Connect external objects.
- Big Data identifies each record with its indexes to avoid duplicate records.
- Big Object support following data types
- Text
- Number
- Date Time
- Lookup
- Long Text Area
- We can create or update big object records in Apex using insertImmediate method and delete the big object records by using deleteImmediate
Create and deploy big object
- Create an .xml file for objects to define object and its custom field metadata and permission sets to give field level security access for the big object metadata as shown below:
- We can deploy objects set in following way:
- Through workbench
- Log into Workbench. Authorize Workbench to access Salesforce Information by clicking Allow (if prompt).
- Under Migration, click on Deploy.
- Create a zip file which contains objects, Permission Sets, profiles and package.xml files. Upload the zip file by clicking choose file button.
- Click Next > Deploy.
- Through workbench
- Through Force.com IDE:
- Create a big object file under the objects folder as shown in image below,
- Define the field definition
- Create the custom fields definition.
- Make sure you have defined the indexes; it should be required field.
- Under the objects, click on the big object you created. Right click and choose com > Save to Server option.
- It will be deployed to your developer instance.
Access to Big Object:
By default, fields are not accessible; we should give access from profile or permission set.
- Go to Setup à Search “Big Objects” in quick find à Big objects.
- List of big objects will be shown here
You cannot change the data type for the custom fields. Once it is defined and deployed to Salesforce, neither we can change the data type, nor we can delete the custom fields.
Following data types are currently supported with big object:
- Text
- Number
- Lookup
- Date time
- Long Text Area
Record creation in Big object:
We can insert the records in big object in the following ways:
- Through Data loader
- Create csv files and insert the record through the data loader.
- Through Apex code:
- We can insert the record with the help of insertImmediate DML operation.
- Below is the sample code to insert the data for each account records.
- If the data exists already, it will update the data.
Conclusion
Big object is used to store and manage the large amount of data effectively in Salesforce.
Reference:
Trailhead link: Big Object Basics
Implementation guide: Big Objects