Newer Version Available

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

SOQL Limits on Objects

SOQL applies specific limits to objects and situations in search results. SOQL limits are defined for the ContentDocumentLink object, external objects, NewsFeed, KnowledgeArticleVersion, RecentlyViewed, TopicAssignment, UserRecordAccess, UserProfileFeed, and Vote.

Some objects or situations have specific limits on SOQL.

Object Description
ContentDocumentLink A SOQL query must filter on one of Id, ContentDocumentId, or LinkedEntityId.
External objects
  • A subquery that involves external objects can fetch up to 1,000 rows of data.
  • Each SOQL query can have up to 4 joins across external objects and other types of objects.

    Each join requires a separate round trip to the external server when executing the query. Expect longer response times for each join in a query.

  • External objects don’t support the following in combination with the ORDER BY clause.
    • Relationship queries
    • NULLS FIRST
    • NULLS LAST
  • External objects don’t support the following aggregate functions.
    • AVG() function
    • HAVING clause
    • GROUP BY clause
    • MAX() function
    • MIN() function
  • The COUNT() aggregate function is supported on external objects whose external data sources support the $inlinecount system query option. Specifically, the response from the external system must include the total row count that’s determined after any $filter system query options are applied.
  • External objects also don’t support the following.
    • EXCLUDES operator
    • FOR VIEW clause
    • FOR REFERENCE clause
    • INCLUDES operator
    • LIKE operator
    • toLabel() method
    • TYPEOF expression
    • WITH clause
NewsFeed
  • No SOQL limit if logged-in user has “View All Data” permission. If not, specify a LIMIT clause of 1,000 records or fewer.
  • SOQL ORDER BY on fields using relationships is not available. Use ORDER BY on fields on the root object in the SOQL query.
KnowledgeArticleVersion
  • Always filter on a single value of PublishStatus unless the query filters on one or more primary key IDs. To support security, only users with the “Manage Articles” permission see articles whose PublishStatus value is Draft.
  • Archived article versions are stored in the articletype_kav object. To query archived article versions, specify the article Id and set sLatestVersion='0'.
  • Always filter on a single value of Language. However, in SOQL, you can filter on more than one Language if there is a filter on Id or KnowledgeArticleId.
RecentlyViewed The RecentlyViewed object is updated every time the logged-in user views or references a record. It is also updated when records are retrieved using the FOR VIEW or FOR REFERENCE clause in a SOQL query. To ensure that the most recent data is available, RecentlyViewed data is periodically truncated down to 200 records per object.
TopicAssignment
No SOQL limit if logged-in user has “View All Data” permission. If not, do one of the following:
  • Specify a LIMIT clause of 1,100 records or fewer.
  • Filter on Id or Entity when using a WHERE clause with "=".
UserRecordAccess
  • Always use the query formats specified in the SOAP API Developer's Guide.
  • May include an ORDER BY clause. You must ORDER BY HasAccess if you SELECT HasAccess, and ORDER BY MaxAccessLevel if you SELECT MaxAccessLevel.
  • Maximum number of records that can be queried is 200.
UserProfileFeed
  • No SOQL limit if logged-in user has “View All Data” permission. If not, specify a LIMIT clause of 1,000 records or fewer.
  • SOQL ORDER BY on fields using relationships is not available. Use ORDER BY on fields on the root object in the SOQL query.

Also, a SOQL query must include WITH UserId = {userId].

Vote
  • ParentId = [single ID]
  • Parent.Type = [single type]
  • Id = [single ID]
  • Id IN = [list of IDs]