Newer Version Available

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

SOQL with Big Objects

You can query the fields in a big object’s index using a subset of standard SOQL commands.

Build an index query starting from the first field defined in the index, without gaps between the first and last field in the query. You can use =, <, >, <=, or >=, or IN on the last field in your query. Any prior fields in your query can use only the = operator.

You can include the system fields CreatedById, CreatedDate, and SystemModstamp in queries.

To guarantee the order of the query results, use the ORDER BY clause.

The following queries assume that you have a table in which the index is defined by LastName__c, FirstName__c, and PhoneNumber__c.

This query specifies all three fields in the index. In this case, the filter on PhoneNumber__c can be a range.

1SELECT LastName__c, FirstName__c, PhoneNumber__c
2FROM Phone_Book__b
3WHERE LastName__c='Kelly' AND FirstName__c='Charlie' AND PhoneNumber__c='2155555555'

This query specifies only the first two fields in the index. In this case, the filter on FirstName__c can be a range.

1SELECT LastName__c, FirstName__c, PhoneNumber__c
2FROM Phone_Book__b
3WHERE LastName__c='Kelly' AND FirstName__c='Charlie'

This query specifies only the first field in the index. The filter on LastName__c can be a range.

1SELECT LastName__c, FirstName__c, PhoneNumber__c
2FROM Phone_Book__b
3WHERE LastName__c='Kelly'

This query doesn’t work because of a gap in the query where FirstName__c is required.

1SELECT LastName__c, FirstName__c, PhoneNumber__c
2FROM Phone_Book__b
3WHERE LastName__c='Kelly' AND PhoneNumber__c='2155555555'

SOQL Operations Not Allowed with Big Objects

  • When building an index query, do not leave gaps between the first and last field in the query.
  • The !=, LIKE, NOT IN, EXCLUDES, and INCLUDES operators are not valid in any query.
  • Aggregate functions are not valid in any query.
  • To retrieve a list of results, do not use the Id field in a query. Including Id in a query returns only results that have an empty ID (000000000000000 or 000000000000000AAA).

    When you use Developer Console to generate a query from a resource, the Id field is included automatically. To query big objects in Developer Console, remove Id from the generated query.

    Note

To perform operations not allowed with SOQL, use Async SOQL instead.