Newer Version Available

This content describes an older version of this product. View Latest

Understanding Bulk API 2.0 Query

Learn about Bulk API 2.0 query availability, supported methods, and SOQL considerations.

Availability

Query jobs in Bulk API 2.0 are available in API version 47.0 and later.

Supported URIs and Methods

This table lists the URIs and methods supported by queries in Bulk API 2.0.

URI HTTP Method Description
/services/data/vXX.X/jobs/query POST

Creates a query job.

/services/data/vXX.X/jobs/query GET

Gets information about all query jobs in the org.

/services/data/vXX.X/jobs/query/queryJobId GET

Gets information about one query job.

/services/data/vXX.X/jobs/query/queryJobId/results GET

Gets the results for a query job.

/services/data/vXX.X/jobs/query/queryJobId PATCH

Aborts a query job.

/services/data/vXX.X/jobs/query/queryJobId DELETE

Deletes a query job.

Chunking Query Jobs

Bulk API 2.0 query jobs enable asynchronous processing of SOQL queries. Instead of manually configuring batches, Bulk API 2.0 query jobs automatically determine the best way to divide your query job into smaller chunks, helping to avoid failures or timeouts. The API automatically handles retries. If you receive a message that the API retried more than 15 times, apply a filter criteria and try again. When you get the results of a query job, the response body is always compressed.

Bulk API 2.0 is optimized to chunk large query jobs with the following objects:

  • Account
  • AccountContactRelation
  • AccountTeamMember
  • AiVisitSummary
  • Asset
  • AssignedResource
  • Campaign
  • CampaignMember
  • CandidateAnswer
  • Case
  • CaseArticle
  • CaseComment
  • CaseRelatedIssue
  • ChangeRequest
  • ChangeRequestRelatedIssue
  • ChangeRequestRelatedItem
  • Claim
  • ClaimParticipant
  • Contact
  • ContentDistribution
  • ContentDocument
  • ContentVersion
  • Contract
  • ContractLineItem
  • ConversationDefinitionEventLog
  • ConversationEntry
  • ConversationReason
  • ConversationReasonExcerpt
  • ConversationReasonGroup
  • CustomerProperty
  • EinsteinAnswerFeedback
  • EmailMessage
  • EngagementScore
  • Entitlement
  • Event
  • EventRelation
  • FeedItem
  • Incident
  • IncidentRelatedItem
  • Individual
  • InsurancePolicy
  • InsurancePolicyAsset
  • InsurancePolicyParticipant
  • Lead
  • LeadInsight
  • LinkedArticle
  • LiveChatTranscript
  • LoginHistory
  • LoyaltyAggrPointExprLedger
  • LoyaltyLedger
  • LoyaltyMemberCurrency
  • LoyaltyMemberTier
  • LoyaltyPartnerProduct
  • LoyaltyProgramMbrPromotion
  • LoyaltyProgramMember
  • LoyaltyProgramPartner
  • LoyaltyProgramPartnerLedger
  • MlRetrainingFeedback
  • Note
  • ObjectTerritory2Association
  • Opportunity
  • OpportunityContactRole
  • OpportunityHistory
  • OpportunityLineItem
  • OpportunitySplit
  • OpportunityTeamMember
  • Order
  • OrderItem
  • Pricebook2
  • PricebookEntry
  • Problem
  • ProblemIncident
  • ProblemRelatedItem
  • Product2
  • ProductConsumed
  • ProductRequired
  • QuickText
  • Quote
  • QuoteLineItem
  • ReplyText
  • ScoreIntelligence
  • ServiceContract
  • Task
  • TaskRelation
  • TermDocumentFrequency
  • TransactionJournal
  • User
  • UserRole
  • VoiceCall
  • VoiceCallRecording
  • Voucher
  • WebCart
  • WorkloadUnit
  • WorkOrder
  • WorkOrderLineItem
  • WorkPlan
  • WorkPlanTemplate

This optimization also includes custom objects, and any Sharing and History tables that support standard objects.

SOQL Considerations

Bulk API 2.0 doesn’t support SOQL queries that include any of these items:
  • GROUP BY, LIMIT, ORDER BY, OFFSET, or TYPEOF clauses.

    Don’t use ORDER BY or LIMIT, as they disable PKChunking for the query. With PKChunking disabled, the query takes longer to execute, and potentially results in query timeouts. If ORDER BY or LIMIT is used, and you experience query time outs, then remove the ORDER BY or LIMIT clause before any subsequent troubleshooting.

  • Aggregate Functions such as COUNT().
  • Date functions in GROUP BY clauses. (Date functions in WHERE clauses are supported.)
  • Compound address fields or compound geolocation fields. (Instead, query the individual components of compound fields.)
  • Parent-to-child relationship queries. (Child-to-parent relationship queries are supported.)