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
Scott.MScott.M 

SOQL Query Limit

Hi,

 

Does anyone know if there's a new soql query record limit in winter 12? We're seeing a 1000 query record limit in winter that wasn't there in summer 11

LoganMooreLoganMoore

Off the top of my head I think the new values are:

SOQL Queries upper limit - 200

Returned number of records upper limit - 2000

 

If you need to handle more than the upper limit of returned records, you could specify the SOQL query inside a for loops definition. Salesforce can transparently handle breaking the SOQL query into batches if too many records are returned. Alternatively, you can use the query and queryMore syntax. Examples on this page.

 http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm

 

 

Scott.MScott.M

Fair enough, but that's a pretty drastic change to make without any mention of it in the release notes, and in our case the query is getting killed at 1000 records, where as it wasn't doing this pre winter 12 upgrade. 

 

LoganMooreLoganMoore

I'm having trouble finding an exact number. I know for sure that the number of queries has increased, but the number of records is still pretty vague, and I'm seeing alot of conflicting information. For instance, that page I referenced specifies in the first sentence.

'Your SOQL query may return so many sObjects that the limit on heap size is exceeded and an error occurs'

 

There may actually be some merit in that statement though, as the following article specifies the upper limit as 50,000.  Which makes me think there is no limit, other than the heap size itself.

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

 

I'm as confused as you now!

LoganMooreLoganMoore

Sorry, I set your wrong in my original post.

 

The winter 12 apex code developers guide concurs with the 50,000 record limit (Page 212). So if there is actually an artificial limit of 1000 records, then that's not good at all?

http://www.salesforce.com/us/developer/docs/apexcode/salesforce_apex_language_reference.pdf 

Scott.MScott.M

That's what I thought it was :) . I'm going to put the query in a loop and see if that fixes things.

JayantJayant

Check for the API version of the class/trigger that has the above code.

This limit used to be 1000 before Winter'11 and 50000 Winter'11 onwards.

In case your code unit is saved with an old version just change the API version and your issue would be resolved.

Scott.MScott.M

That's the weird thing though, prior to the winter 12 release, a class with api version 22 didn't hit the limit and then right after the upgrade it started hitting it. Putting the query in a for loop fixed the problem