Introduction
Big Object – A feature that addresses the data Challenges in Salesforce Platform “Big Data -> Force.com”
In general, Standard and Custom Objects in Salesforce are used to store data with limits whereas big objects are used to store large amount of data in Salesforce (i.e. 1million, 100million or 1billion). The data stored in the Big Object can be used within the Force.com as well as by the external application with the set of API’s.
Types of Big Objects
- Standard Big Object – available by default in Salesforce (Field History Archive)
- Custom Big Object – created as per our needs using Metadata API
Why do we need a Big Object?
- Customer 360 – Complete view of customer
- Historical Data Archive / Data Lake
- Audit and Tracking
- To perform Data Analytics
How to access the records stored in Big Objects?
SOQL – Can retrieve records within the governor limits
Async SOQL – Can retrieve billions of records
Considerations for Big Object
- We must use Metadata API to define a custom Big Object and field
- We can create only 100 Big Objects per org
- Big objects do not support triggers and processes and flows
- Big Objects are read only after creation (No page Layouts)
- Normal Reports are not supported for Big Objects but for only Einstein Analytics
Big Object Implementation
- Object File
- Permission Set File
- xml
Note: The only fields that we can create for Big Objects are
- Text and Long Text Area
- Number
- Datetime
- Lookup to Standard or Custom Object (Relation)
Refer the below link for Implementation
Reference 1 : https://www.mstsolutions.com/technical/salesforce-bigobjects/
Reference 2 : https://trailhead.salesforce.com/en/content/learn/modules/big_objects
Populate Custom Big Object
- Bulk API(CSV)/Soap Tool/REST API
- Apex Code – Database.insertimmediate(ob)
- Async SOQL – insert
How to view a Big Object?
- Visual Force Page
- Lightning Component
To view the big object on the UI, we need to create a Visualforce page with a Controller by returning the fields in Big Object. By calling the fetch method, the data that are feed into the Big Object are displayed in a table format
Using a normal SOQL query to retrieve billion records would be a challenge and a time-consuming process. The solution for this is the Async SOQL Query which helps us to retrieve a large amount of data quickly
Async Query
Async query runs in the background over salesforce entity data, Standard Object, Custom Object, Big Object and External Object
This Async Query is used to
- Create a record
- As well as query records
Note: Only if the asynchronous query is enabled for the Org, we will be able to use async query operations
The Key Values that play a main role in the Async Query Request body
Query – specifies the parameter for execution
Operation – what operation to be performed (e.g. Insert)?
Targetobject – An object into which the Operation is to be performed
TargetFieldMap – Map fields with the Targetobject fields
Sample Async SOQL using POST request body
(“query”: “SELECT College__c,Department__c,Enrollment_ID__c,Student_Name__c,TotalMarks__c FROM Student__b”
“operation” : “insert”,
“targetobject”: “Student__b”,
“targetFieldMap”: (
“College__c” : “College__c”
“Department__c”: “Department__c”
“Enrollment_ID__c”:” Enrollment_ID__c”
“Student_Name__c”:” Student_Name__c”
“TotalMarks__c”:” TotalMarks__c”}
Delete Data in Custom Big Object
An Apex Method, DeleteImmediate() can be used to delete rows in the custom Big Object where we have to declare the Sobject(acts as Template) that is used in the index and also with the fields that map with the Custom Big Object by using the WHERE clause
Example Apex code to Delete Row in a Custom Big Object
List <Student__b> sBO = new List<Student__b>();
sBO.addAll([SELECT Department__c, Enrollment_ID__c, College__c, Student_Name__c, TotalMarks__c FROM Student__b where Department__c = ‘a036F000018mWhKQAU’]);
Database.DeleteImmediate(sBO)
Difference between Custom Object and Big Object