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
Tanuj TyagiTanuj Tyagi 

Getting Warning for governor Limit. Need Urgent Help !!

Hi All,

From past few days, after Winter 19 release. 
We are getting regular Warning Emails in Production org related to Governor Limits .
Below is the sample Email :

Subject: Apex governor limit warning

Caused the following Apex resource warnings:

Number of query locator rows: 10000 out of 10000

Please let me know if they can be ignored or is it something to be taken care of ?
Raj VakatiRaj Vakati
Looks like your batch class is running on huge data that cases this email .. i think its not related to winter 19 ..

Check the batch class or apex class .. it may bebecauses of the data volume 

 
Tanuj TyagiTanuj Tyagi
@RajVakati  Hi Raj , Thanks for your response.

Actually, Its not a batch Class. Normal Apex Class .
This is the code :

 Database.QueryLocator ql = Database.getQueryLocator('select id from Object LIMIT 10000');

Any good alternative for this ?

Shall I increase the limit upto 50k or replace getQueryLocator with database.query()  Or any other Approach ?
Raj VakatiRaj Vakati
Instead of limiting to 10000 .. use database.query()  where you will get more limit 
Tanuj TyagiTanuj Tyagi
Thanks Man
Raj VakatiRaj Vakati
Its wokred ? 
Raj VakatiRaj Vakati
database.query in Salesforce allows you to make a dynamic SOQL query at runtime. You can build up a string and then use that as a query string at run time in the database.query statement to make a SOQL call that is determined at run time. In Batch Apex, if you use Database.query(), it supports 50,000 records only.
 
database.getQueryLocator in Salesforce returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in batch apex or used for displaying large sets in VF (allowing things such as pagination). In Batch Apex, if you use Database.getQueryLocator(), it supports upto 50 million records.
Tanuj TyagiTanuj Tyagi
Yet to Deploy. Will update you once its done.
Thanks Raj