Is there a way to know programmatically what are SOQL limits on objects? some way that given a standard object tells that to query this object you need to use filters on the fields [x,y,z,...]?

to avoid exceptions like this:

[MalformedQueryFault [ApiQueryFault [ApiFault exceptionCode='MALFORMED_QUERY' exceptionMessage='Implementation restriction: ContentDocumentLink requires a filter by a single Id, ContentDocumentId or LinkedEntityId using the equals operator']

I know these limits are stated in the documentation but I need a on-the-fly way


  • I suspect you may want to be looking at Schema Describe methods used for Dynamic Apex. This example from the docs seems relevant to what you've cited.
    – crmprogdev
    Commented Nov 9, 2014 at 19:28
  • There is DescribeSObjectResult.queryable and .fields filterable. However, I suspect these are not sufficient for the special case limits on Objects that you linked to. E.g. There is no description of a required filter field or limits on the number of records that will be returned based on not having the "View All Data" permission. FilteredLookupInfo was added in v31.0, but I haven't checked it yet. Commented Nov 9, 2014 at 20:28
  • Similar question on the Discussion Forums: How to now the filters needed for SOQL query for Standard Objects? Commented Nov 10, 2014 at 1:15

1 Answer 1


I'm going to go out on a limb here and say that, no, you can't use the currently available meta data to determine the special query requirements as outlined in SOQL Limits on Objects.

Take for example, ContentDocumentLink. The special SOQL requirement here is:

A SOQL query must filter on one of Id, ContentDocumentId, or LinkedEntityId.

There is currently no meta data in DescribeSObjectResult that can tell you that one of those fields must defined in the SOQL where clause.

You have queryable on DescribeSObjectResult and filterable on Field. However, there is currently no way to know which combination of fields are required.

With NewsFeed the requirement is:

No SOQL limit if logged-in user has “View All Data” permission. If not, specify a LIMIT clause of 1,000 records or fewer.

Again, there is no meta data available to indicate that a LIMIT clause is required or what the maximum value is based on the users permissions.

  • 1
    are those limits applied to the bulk API too?
    – Sara
    Commented Nov 11, 2014 at 11:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .