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
Eager-2-LearnEager-2-Learn 

Query produces different Total Records

Hi,

 

This query produces 16,325 when reported in my test (failed because of the 10k limit) but the numbers are the focus here.  The 16,325 is coming from the error message about to many rows. 

 

System.LimitException: Too many query rows: 16,325

 

When I use the same query and export using the DataLoader I get 13,939 records.

 

Does anyone know the reason for this difference?  I even tried using the IsDeleted = false in the WHERE clause and the numbers still do not match.

 

The query is:

 

Select id, MissingPartner__c, Last_Modified_By_User__c, LastModifiedBy.Name, LastModifiedDate, (Select id From OpportunityPartnersFrom)

From Opportunity

 

 

I am going to to keep workiing on SFDC Governor Limits until I figure out why I can't get nothing done!!! :) Am a alone with this.  Do something SFDC. :(

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
User@SVFUser@SVF

I think, salesforce counts the rows being retrieved in the subquery against the query limits which is not the case when you use the data loader. say, if your subquery is retrieving 3k+ rows while your outer query retieves 13k rows.

 

 

All Answers

forecast_is_cloudyforecast_is_cloudy

One guess could be that you're using different user ids for the Data Loader vs the Apex code. Maybe the Data Loader user have limited acces to Opportunity data due to Role Hierarchy/Sharing Rules etc.?

As you said though, it doesn't matter if its 16K or 13K, either way you're breaching the 10K limit and will have to refactor the SOQL query somehow.

Hope this helps...

Eager-2-LearnEager-2-Learn

I am logging into the DataLoader as myself and I am logging into SFDC and running the code as myself; therefore, I am not certain that ID would be different, would it?

 

There are just so many crazy things with SFDC programming that I barely get much done.  If it wasn't for this forum I would be in even more trouble.

 

I have been working on trying to us Apex Batch and I finally have it working in DEV (little amount of data).  I am close to moving it to the Sandbox where I have those 16K+ records.  I hope it works; otherwise I am going to have to split several runs with date range changes.  This is not the type of code I want in production.  My code should work for any amount of data into the future.  I don't want to get in the habit of excepting 10k or less is all that my code may ever process.  I don't care if it take a larger effort to implment the code, it must deal with the possibility of data larger than 10k (size of a pea in todays world of data).  My personal baseball card collection is larger than 10K records that is in an MS Access database for goodness sake.

 

Thanks for working with me on this I do appreciate it more than you can imagine.

User@SVFUser@SVF

I think, salesforce counts the rows being retrieved in the subquery against the query limits which is not the case when you use the data loader. say, if your subquery is retrieving 3k+ rows while your outer query retieves 13k rows.

 

 

This was selected as the best answer