Created
November 26, 2023 22:14
-
-
Save brianmfear/516154d0a96e0f6b17cac2f1f84434f0 to your computer and use it in GitHub Desktop.
SSCCE of running a 250k character SOQL query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WARNING: uses lots of CPU time, set all log levels to NONE, Apex to ERROR. | |
String[] charset = new String[0]; | |
for(Integer i = 48; i < 58; i++) { | |
charset.add(String.fromCharArray(new Integer[]{i})); | |
} | |
for(Integer i = 65; i < 91; i++) { | |
charset.add(String.fromCharArray(new Integer[]{i})); | |
} | |
for(Integer i = 97; i < 123; i++) { | |
charset.add(String.fromCharArray(new Integer[]{i})); | |
} | |
String genRndStrFastPRNG(Integer len) { | |
String[] chars = new String[len]; | |
Integer key, size = charset.size(); | |
for(Integer idx = 0; idx < len; idx++) { | |
chars[idx] = charset[Math.floor(Math.random()*size).intValue()]; | |
} | |
return String.join(chars,''); | |
} | |
String[] filters = new String[0]; | |
for(Integer i = 0; i < 1000; i++) { | |
filters.add('Name = \'' + genRndStrFastPRNG(250)+'\''); | |
} | |
String query = 'SELECT Name FROM Account WHERE (' + | |
String.join(filters, ') OR (') | |
+')'; | |
Database.query(query); | |
System.debug(LoggingLevel.ERROR, 'Query String Length: '+query.length()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment