The maximum length for a SOQL (Salesforce Object Query Language) statement is 100,000 characters. This is a hard limit enforced by Salesforce to ensure platform stability and performance. This limit cannot be increased by customers; adjustments can only be made by Salesforce Product Management at their discretion.
You may encounter this limit when constructing SOQL queries with many fields, complex formulas, or large numbers of currency fields.
Common causes of reaching the character limit or triggering QUERY_TOO_COMPLICATED include:
Divide the single large query into multiple queries that each retrieve a smaller subset of fields.
Formula fields are expanded internally when Salesforce processes a SOQL statement. A query that appears to be within the 100,000 character limit may exceed it after formula expansion. Remove formula fields from the SOQL query where possible, or calculate formula values in Apex code rather than querying them directly.
Each currency field causes Salesforce to internally use a format() method, which roughly doubles the length contributed by that field to the query. Reduce the number of currency fields included in a single query. Split currency field retrieval into a separate query if necessary.
If the QUERY_TOO_COMPLICATED error occurs on a Lightning record page without any custom SOQL, the issue is likely caused by the number of fields on the page layout. Lightning Experience auto-generates SOQL to retrieve fields for record pages. Reduce the number of fields on the page layout to fewer than 250 fields.
000386440

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.