function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

10K SOQL Statement limitation

The 10K character limit on SOQL statements is causing major headaches as we add custom fields to an objectAs soon as you have around 325 fields with 30 character field name you start to hit this issue because the Select SOQL statement blows the limit.


Even when you write code to split the select list and get two query resultsyou can't 'ORDER BY ID' in SOQL to make the join of the two query results easier. When you are dealing with millions of rows, the 10K limitation forces you into writing a complicated merge/join logic for million row data streams. Also, there is no guarantee that the two query results will have the same number of rows because there is no ability to 'lock' the table so the query results are the same (i.e a row could be deleted between the time of the two queries. Now, you are writing merge join logic where there could be a row in one stream but not in the other.


Is it possible to add 'Select *' to the SOQL language so that we can avoid this ?


How have others dealt with this limitation ?



Greg HGreg H

We try to limit the length of the text used for the field names. Typically, we keep the field labels as normal text and somewhat long, when needed, but try to condense the field names to prevent this 10k limit. As a developer this can become confusing when your field names are somewhat cryptic but the end-users don't know the difference because they read the field labels within the app. You could go back and reduce the number of characters in those field names on all your custom fields but this will impact any development you've already done.


Hi Greg,


Does the character limit include where clause characters too? However I tried dynamic soql with more that 10K characters in where clause and it works -  Database.query('Select id From Contact Where Id In ('a069000000GVD2bAAH','a069000000GVD2cAAH','a069000000GVD2dAAH', ..............................));