Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This error occurs when the length of the SOQL statement is too long and fetches a large number of fields. In other words, the query may be too long or complex.

Solution

...

Background

Salesforce has a set limit on the length of a query to ensure the system runs smoothly for all customers. When a query is too long and fetches a large number of fields, the user may hit this limit. Some reasons for this error have to do with the way Salesforce processes queries.

Another reason for this error is Lightning page layouts with more than 250 fields. Salesforce uses queries to get the fields for the layout. For this reason, the QUERY_TOO_COMPLICATED error can arise, even if there are no custom queries.

Finally, the query length can be too long due to using too many currency fields. Currency fields use twice as many characters as other fields and can make queries too long.

For more informationPulsar is a mobile app that uses the out-of-the-box API published by Salesforce. This means Pulsar is subject to the limits that Salesforce has placed on queries. Pulsar must also request each field by name, and not use shortcuts (such as * ) to request all fields from an object, which results in longer queries.

Solution

It is best to reduce the complexity of queries. Either reduce the length (characters) of the query or the number of fields it returns.

Another way to reduce the query complexity is to reduce the number of fields contained in an object. Salesforce suggests creating related objects to keep the complexity low.

For more information on this topic, refer to Salesforce Documentation - Maximum length for SOQL statements.

...