Salesforce Big Object and Async Query | Async SOQL Big Object in Salesforce : Bijay Kumar

Salesforce Big Object and Async Query | Async SOQL Big Object in Salesforce
by: Bijay Kumar
blow post content copied from  SalesForce FAQs
click here to view original post



### Summary of Async SOQL in Salesforce **Async SOQL Overview:** - Async SOQL, or Asynchronous SOQL, is used in Salesforce to run queries on large datasets asynchronously, processing them in the background while you continue to work on other tasks. - It is specifically designed for handling massive amounts of data, such as records in Big Objects, allowing for efficient querying of up to 1 million records. **Big Objects in Salesforce:** - Big Objects are Salesforce entities that store huge volumes of data without consuming standard object storage limits. They can manage billions of records, which makes querying them via regular SOQL methods challenging due to performance impacts. - As of Summer 2023, Async SOQL for Big Objects is no longer supported in Salesforce. Users must now utilize the Bulk API or batch Apex for querying Big Objects. **Alternative Methods:** - To query Big Objects, follow these steps using the Bulk API: 1. Ensure that the Bulk API is enabled in your organization. 2. Use indexed fields in your SOQL queries for efficient data retrieval. 3. Execute Bulk API queries either in the Developer Console or via tools like Salesforce Workbench. 4. Follow specific syntax and procedures to create and manage bulk query jobs. **Conclusion:** The tutorial emphasizes that while Async SOQL is retired for querying Big Objects, the Bulk API offers a viable alternative for efficiently accessing and managing large datasets in Salesforce. ### Additional Context Async SOQL was a popular feature for Salesforce developers needing to manage large data queries without interrupting their workflow. With its retirement, understanding the Bulk API and how to effectively index data becomes crucial for Salesforce users handling significant volumes of information. ### Relevant Hashtags for SEO #Salesforce #AsyncSOQL #BigObjects #BulkAPI #SalesforceTutorial #DataManagement #SOQL #SalesforceDevelopment #SalesforceQueries #CloudComputing


In Salesforce,  Async SOQL means Asynchronous SOQL. It is an asynchronous process in which we run the SOQL queries over the Salesforce entity data, including subjects, BigObjects, and external objects.

In this Salesforce tutorial, I will explain async SOQL in Salesforce and how to query big objects using Async SOQL.

What is Async SOQL in Salesforce?

In Salesforce, Async SOQL is an asynchronous process used to efficiently handle large amounts of data. Unlike regular SOQL, which processes queries immediately, Async SOQL runs in the background, allowing you to work on other tasks while it processes. It is particularly useful for querying millions of records, such as data stored in Big Objects.

In the Async SOQL queries, the results are stored in a target object for further use. It can query large amounts of data stored in Salesforce, where we can query up to 1 million records, and for extra capacity, we need an add-on license.

Async SOQL Big Object in Salesforce

In Salesforce, Big Objects are used to handle massive amounts of data that our organization accumulates over time. They store and manage billions of records, providing a way to archive data or log records without consuming standard object storage limits.

Due to the large data size of the big objects, it is difficult to query them through the common SOQL methods because it impacts the performance due to the large data size. To resolve this, we use the Async SOQL, an asynchronous query method specifically used for efficiently querying Big Objects.

Salesforce Big Objects Async SOQL Retirement

In the release of summer 2023, the Async SOQL feature of Big Objects is not supported in Salesforce. When performing Asynchronous SOQL on Big Objects, you must use the Bulk API or batch Apex to query or report on custom Big Objects after upgrading your org to the Summer ’23 release. After the update, no jobs running Async SOQL will be available.

What is the alternative to Async SOQL for querying Big Objects?

As an alternative to the Async SOQL, we will query big objects using the bulk API method and the Salesforce workbench.

Querying Big Objects using Bulk API in Salesforce

To query Big Objects in SOQL, the Big Objects require a defined index for efficient querying. Ensure you have indexed fields to query data.

The big object should have an indexed field, and the query must include indexed fields in the WHERE clause.

If the above conditions are true for your organization, then follow the steps below.

1. First, ensure that bulk API is enabled in your org, and for that, navigate to Setup > Feature Settings > Data > Bulk Data Load Jobs.

2. Now, in the developer console query editor, execute the SOQL query with the below syntax and ensure that indexed fields are included in the WHERE clause.

Syntax:

SELECT Field1, Field2 FROM BigObjectName__b WHERE IndexedField1 = 'value'

In my org, I have a custom object Customer_Interaction__b with the indexed field, so I have executed the query in the following way.

SELECT Customer_ID__c, Interaction_Date__c, Interaction_Type__c FROM Customer_Interaction__b
WHERE Interaction_Type__c = 'Phone'
AND Interaction_Date__c = 2024-12-11T00:00:00.000Z

Output:

Big Object query in Salesforce

In the output, you will see the records retrieved from the Salesforce Big Object.

3. We can also use tools like Salesforce Workbench. There, we have to navigate to workbench.developerforce.com and log in with the Salesforce account credentials.

4. In the workbench, select Jump to: SOQL query, then Big Object from the Object lookup field, and click on the Select button.

5. Paste the SOQL query defined with the WHERE clause and execute it.

Query big objects with API in Salesforce

In the query results, you will see the records that are true with the conditions in the SOQL query.

6. To create a bulk query job, click on the utilities tab and select REST Explorer.

REST API to query Big Objects in Salesforce

7. In the REST Explorer, select the POST and enter /services/data/v62.0/jobs/query. Here, v62.0 is the version of my org.

You can check the org version from Setup> Apex Classes. Then, in the column API version, you can see the version of your org.

Then, enter the SOQL query; in the request body, enter the below code and click on the Execute button.

{
  "operation": "query",
  "query": "SELECT Customer_ID__c, Interaction_Date__c, Interaction_Type__c FROM Customer_Interaction__b WHERE Interaction_Type__c = 'Phone' AND Interaction_Date__c = 2024-12-11T00:00:00.000Z"
}

8. We will get the operation details after a successful POST API run. Here, we have to copy the job ID that we will use in the GET API method to get the results.

SOQL Big objects in Salesforce through API

9. Now, enter the GET API with the following address and execute it.

/services/data/v62.0/jobs/<job id>/results
Get results of BIG objects SOQL in API

When processing and querying the large data records of the Salesforce Big Objects, it might take some time to process the batch.

The alternate way to check queried results is by navigating to Setup> Bulk data Jobs. Here, you have to click on the job batch id.

Then scroll down to the section Batches and click on the button view result to view the records.

Salesforce Big Object query records

This way, we can query the Big objects using Bulk API in Salesforce.

Conclusion

In this Salesforce tutorial, we have learned about the async SOQL in Salesforce, and since the Async SOQL is retired, we have discussed the alternative method to query big objects in Salesforce, where we queried big objects using Bulk API.

By following this method, you will be able to query bulk data from the big objects in Salesforce.

You may also like to read:

The post Salesforce Big Object and Async Query | Async SOQL Big Object in Salesforce appeared first on SalesForce FAQs.


December 22, 2024 at 05:10PM
Click here for more details...

=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce