Friday, 24 November 2017

Big Object - Bring Big Data In Salesforce

Big Object

Hi guys today I am going to discuss about Big Object  in salesforce. Big Object allows you to store tons of data into salesforce platform. It provide consistent performance whether there are 1 million records or 1 Billion records . But we can store data in custom object also then why we use Big Object .

Big object is worth to use if you want to store historical data.

Eg. All the Case record which are closed and were created years ago.
Transaction history of a user.  

There are 2 type of Big Object In salesforce.

  1. Standard Big Object : These Object are defined by Salesforce itself.
  2. Custom Big Object :These Object are defined by user in its Salesforce org.

Custom Object VS Big Object :

Sr no
Custom Object
Big Object
Suffix is __c
Suffix is __b
Can be created from UI.
Can’t be created from UI. We must need  to use metadata api to create Big Object and add field to Custom Big Object
Support standard ui element such as list view , details page.
Do not support standard ui element such as list view , page layout.
Standard Reports and Dashboard are available.
Standard Report and Dashboard are not available.
Limit for maximum no of Custom Object can be created in org. Depend on the license type. In developer Org it is 400.
Limit for maximum no of Big Object can be created in org. Depend on the license type. In developer Org it is 100.
Triggers, flow and process builder are available.
To support  the scale of data in Big Object Triggers, flow and process builder are not available.
Support lot of data types.
Support DateTime, Lookup, Number, Text, and LongText Area only
Custom fields can be deleted.
Custom fields can not be deleted once created.
Records can be updated and deleted.
Records Can’t be deleted once inserted.

How to Define and Deploy Big Object :

To define and deploy Big Object we need to make metadata. After deploying we can view in setup ui under Customize >> Create >> Big Object

Define a Big Object : Define a custom big object through the Metadata API by creating XML files that contain its definition, fields, and index . Files we need are specified below.

  1. Object File :- Create a .object file. The name of file should be similar to API of object. Eg. myobject__b.object
  2. permissionSet/Profile file :- This file is not required. We create permissionSet or profile file to give access permission for each field.
  3. package.xml  :- Create a file for the metadata package to specify the contents.

Let’s see an example. We are creating a Big Object Employee (You can also download source file. Click here)
So 1st we will make an Employee__b.object file . It will look like this.

<?xml version="1.0" encoding="UTF-8"?> <CustomObject xmlns=""> <deploymentStatus>Deployed</deploymentStatus> <fields> <fullName>First_Name__c</fullName> <label>First Name </label> <length>50</length> <type>Text</type> <unique>false</unique> <required>true</required> </fields> <fields> <fullName>Salary__c</fullName> <label>Salary</label> <type>Number</type> <scale>2</scale> <precision>16</precision> <required>false</required> <unique>false</unique> </fields> <fields> <fullName>Dob__c</fullName> <label>Date Of Birth</label> <type>DateTime</type> <required>false</required> <unique>false</unique> </fields> <fields> <fullName>Contact__c</fullName> <label>Contact</label> <referenceTo>Contact</referenceTo> <relationshipName>Employee_Con</relationshipName> <type>Lookup</type> </fields> <indexes> <fullName>EmployeeIndex</fullName> <label> Employee index</label> <fields> <name>First_Name__c</name> <sortDirection>DESC</sortDirection> </fields> </indexes> <label>Employee</label> <pluralLabel>Employee</pluralLabel> </CustomObject>
Now we will make perssionSet File. It’s extension will be .permissionSet

<?xml version="1.0" encoding="UTF-8"?> <PermissionSet xmlns=""> <fieldPermissions> <editable>true</editable> <field>Employee__b.firstName__c</field> <readable>true</readable> </fieldPermissions> <fieldPermissions> <editable>true</editable> <field>Employee__b.email__c</field> <readable>true</readable> </fieldPermissions> <fieldPermissions> <editable>true</editable> <field>Employee__b.salary__c</field> <readable>true</readable> </fieldPermissions> <fieldPermissions> <editable>true</editable> <field>Employee__b.dob__c</field> <readable>true</readable> </fieldPermissions> </PermissionSet>
In last we need package file. (package.xml)

<?xml version="1.0" encoding="UTF-8"?> <Package xmlns=""> <types> <members>*</members> <name>CustomObject</name> </types> <types> <members>*</members> <name>PermissionSet</name> </types> <version>41.0</version> </Package>

Deploy Custom Big Object : We are using workbench to deploy. To create zip (package) file for deploying custom Big Object make sure that the object file should be in objects folder, permissionSet file should be in permissionSets folder and the package.xml file should be in root directory (must not inside any folder).

See the image

Once you have successfully deployed Big object you can view them under Big Object in setup ui .

When we see the details of Employee Big Object we see that there is no button is available for delete and create new custom field . What if we want to add some new fields and want to delete any of existing.
Let me clear this that you can’t delete a custom field created on Big Object.  To add new custom field we will go through metadata deployment.

Add new Custom Field to Custom Big Object :-  Earlier we created  a custom Big Object . Now we want to add a new custom field in it.
We need to create an .object file with the same name of previous one (Employee__b.object). It will contain the following code
<?xml version="1.0" encoding="UTF-8"?> <CustomObject xmlns=""> <deploymentStatus>Deployed</deploymentStatus> <fields> <fullName>Last_Name__c</fullName> <label>Last Name </label> <length>50</length> <type>Text</type> <unique>false</unique> </fields> <label>Employee</label> <pluralLabel>Employee</pluralLabel> </CustomObject>
And now we will deploy it using workbench. For deploying we will follow the previous example structure . This time we are not using permissionSet file . package.xml will be same as previous. After deployment we can see there is new Custom  field Last Name on Employee__b Big Object.  

Insert Data into Big Object :
Using CSV :- To insert data into Big Data we can upload csv file using data loader.

Using Apex Code :-  Using Database.insertImmediate() we can insert data into Big Object.
Here is the snippet using  it you can insert data into our Employee Object.
List<Employee__b> listOfEmp = new List<Employee__b>(); Employee__b objEmp = new Employee__b(); objEmp.first_Name__c = 'Naveen'; objEmp.Salary__c = 5000; objEmp.Last_Name__c = 'Soni'; listOfEmp.add(objEmp); Database.insertImmediate(listOfEmp);

Note : Big objects don’t support transactions including both big objects, standard object and        custom objects
Then How can we Insert records in Big Object. Solution is “Async SOQL”, we will go through it in next steps.
If you are not able to insert record in then check for field permission for your profile. Even if you are a system administrator .

Update  Data into Big Object :  

Code snippet :

List<iarpit__Employee__b> listOfEmp = new List<iarpit__Employee__b>(); for(iarpit__Employee__b objEmp : [SELECT iarpit__First_Name__c, iarpit__Last_Name__c FROM iarpit__Employee__b WHERE iarpit__First_Name__c='Ankit']){ iarpit__Employee__b objEmp1 = new iarpit__Employee__b(); objEmp1.iarpit__last_name__c = 'rohit'; objEmp1.iarpit__first_name__c = objEmp.iarpit__first_name__c; listOfEmp.add(objEmp1); } System.debug(listOfEmp); if(listOfEmp.size() > 0){ Database.insertImmediate(listOfEmp); }

Want to view records of Big Object :-

As I already mention that there is no standard ui is available for Big Object. So if we want to see data then we can create our custom visualforce page and view data on it.

Here I created a vf page which display first name and last name of employee.


public class BigObjExample{ public List<Employee__b> listOfEmp {get;set;} public BigObjExample(){ listOfEmp = [SELECT iarpit__First_Name__c, iarpit__Last_Name__c FROM iarpit__Employee__b ]; if(listOfEmp == null){ listOfEmp = new List<Employee__b>(); } } }
<apex:page controller="BigObjExample" title="Big Object Example"> <apex:sectionHeader title="Employee" subtitle="All Employee"/> <apex:pageBlock> <apex:pageBlockSection columns="1"> <apex:pageBlockTable value="{!listOfEmp}" var="emp"> <apex:column value="{!emp.first_name__c}"/> <apex:column value="{!emp.last_name__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

Screenshot ;

SOQL In Big Object  :-
There are some limitation for soql query on Big Object. We can use all the fields in ‘WHERE’ , all operators are not supported.
Only the indexed fields can be used in WHERE condition in soql.
You can use =, <, >, <=, or >=, or IN on the last field in your query. Any prior fields in your query can only use the = operator. The !=, LIKE, NOT IN, EXCLUDES, and INCLUDES operators are not valid in any query
Async SOQL :  
When we want to query large amount of data we go for  Async SOQL .
Async SOQL queries are run in the background over Salesforce entity data, standard objects, custom objects, and big objects.
Async SOQL is implemented as a RESTful API that enables you to run queries in the familiar syntax of SOQL.
Result of each Async SOQL query are being stored in another object which you define. It can be a Standard , Custom or Big Object.
Note :Async SOQL for standard and custom objects are not generally available.
URL on which we send request for Async SOQL
We set query in the body of HttpRequest.
Example of Query :-
{ "query": "SELECT iarpit__First_Name__c FROM iarpit__Employee__b", "operation": "insert", "targetObject": "iarpit__BigEmp__c", "targetFieldMap": {"iarpit__First_Name__c":"name"} }
In this I have created a Custom Object BigEmp__c
Snippet of class using we can send request for Async SOQL :-
/* Name : BigObjectToCustom Date : 07/11/2017 Author : Arpit Vijayvergiya Description : this is being used for transfering data from Big object to Custom object */ public class BigObjectToCustom{ public BigObjectToCustom(){ String query = '{"query": "SELECT iarpit__First_Name__c FROM iarpit__Employee__b","operation": "insert","targetObject": "iarpit__BigEmp__c","targetFieldMap": {"iarpit__First_Name__c":"name"}}'; Http http = new Http(); HttpRequest request = new HttpRequest(); request.setMethod('POST'); request.setEndPoint(''); request.setHeader('Content-Type', 'application/json'); request.setBody(query); request.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID()); HttpResponse response = http.send(request); System.debug(response.getBody()); } }
Note : As per the winter 18 release doc “Async SOQL is included only with the licensing of additional big object capacity.

If we are not having additional permission then we will be getting this message in response.

“ [{"message":"This feature is not currently enabled for this user type or org: [AsyncQuery]","errorCode":"FUNCTIONALITY_NOT_ENABLED"}] ”



  1. well explained blog arpit. keep it up..
    waiting for your next blog

    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. This is good and helping to understand big object. Right now there is less amount of article are there. Keep it up. You are doing very good.

  3. Very helpful blog ...waiting for another these type of blogs from ur side.

  4. Very helpful blog ...waiting for another these type of blogs from ur side.

  5. Nice blog. One thing that you can definitely update records in big object but you can't delete them. Insertimmediate will do the update operation as well if we map the index fields correctly.

  6. Hi,
    I'm getting an Error while executing Async SOQL as "errorCode":"INSUFFICIENT_ACCESS","message":"You don’t have permission to query this object Account with Async SOQL.
    What Permissions I have to give ,Am I Missing anything here ...Please Let Me Know Thanks in Advance

  7. @Mubeena - Make sure you have big object permission..Go to your profile and permission set and check for the access.

    1. This comment has been removed by the author.

    2. @Prashant Pandey I checked for profile and permission set but no use i'm getting same error "errorCode":"INSUFFICIENT_ACCESS","message":"You don’t have permission to query this object Account with Async SOQL. while inserting records from standard or custom object into bigobject.

  8. Very Nice Blog and very well explained.

  9. Hi Arpit,

    I am facing problem: No package.xml found. can you tell my why I am facing it.
    If I download your file it is working fine. but If I unzip it and again zip same file then getting problem: No package.xml found error.
    can you help me to overcome to it.


  10. I get the error "Path must start with /" when I use the custom URL Link When I use the /services/data/v41.0/async-queries/ URL I get the 'Insufficient_Access" error message even though I am the System Admin and I have checked to make sure that I have full permission on both the Custom_Object__c and Big_Object__b.

  11. Hi Arpit,

    I have done all the steps mentioned above and can see data inside big objects through Visualforce Page. But after uploading more than 1000 records, it gives me error as "Collection size 1,486 exceeds maximum size of 1,000" .I have overcome this error before by introducing pagination for vf pages, but bog object does not support Offset, so what can be used to correct this issue?


  12. Thank you for sharing your article. Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums.

    java training in chennai

  13. Very good information. Its very useful for me. We need learn from real time examples and for this we choose good training institute, we need to learn from experts . So we make use of demo classes . Recently we tried Big Data demo class of Apponix Technologies.

  14. how to resolve this error : -
    “ [{"message":"This feature is not currently enabled for this user type or org: [AsyncQuery]","errorCode":"FUNCTIONALITY_NOT_ENABLED"}] ”

  15. Is there any way to deploy zip(package) file through apex.

  16. Thanks for sharing useful information on big data technology. Bigdata is going to be future of the computing world in the coming years. This field is a very good option that provides huge offers as career prospects for beginners and talented professionals. So, taking bigdata training institute in bangalore will help you to start good career in big data technology.

  17. Thank you for sharing the very useful information. It has helped me a lot. Thank you

  18. I am definitely enjoying your website. You definitely have some great insight and great stories. for more info

  19. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. here

  20. Web Host Review - After being shut down without warning, you will learn how to review your web hosting provider before handing over your credit card. top web hosts in 2020