I simply try to execute a batch job and execute a SOQL inside the execute() method as below with having,
- execute() method has the line List results = (List)database.query(query); , and
- start() method queries 10000 records (SELECT Id FROM statustracking__c LIMIT :recordsLimit)[**see the note], and
- batch size is 2000 and,
- I do not have any long text fields/attachments or such kind of large content fields
trying to execute the above batch resulting the below error;
"Query of LOB fields caused heap usage to exceed limit."
Can someone explain/suggest;
why the error is thrown even the record limit is 10000?
are there any alternative ways that I could process 100000 except PK chunking? (this much is what I actually want to process)
"query" variable in the first point contains the below SOQL;
SELECT ownervalue__c, managerlevel3__c, isdeleted, ownerid__c, previous_owner__c, enddate__c, isteammanager__c, iscreatorloggedin__c, id, networkresponsevalue__c, createddate, createddatelist__c, managerlevel1__c, statusduration__c, status__c, fieldschanged__c, ownername__c, startdate__c, assignedbyfillinbox__c, createdbyid, statusvalid__c, lastmodifiedbyid, previous_owner_id__c, recordtypeid, agent__c, duration__c, lastmodifieddate, ischannelmanager__c, businesstime__c, durationmins__c, previous_owner_name__c, day_of_the_week__c, networkcommentsvalue__c, systemmodstamp, durationhours__c, managerlevel2__c, creatorrole__c, ignore__c, fax__c, network__c, businesshours__c, business_hours_status__c, case__c, name, escalationtier__c, business_hour_duration__c, ccmanager__c, subsequentstatusvalue__c, start_date_hour__c, durationseconds__c, statusvalue__c, case_contact_id__c, creatorprofile__c FROM statustracking__c WHERE id NOT IN (SELECT statustracking__c FROM archivelog__c WHERE sobjecttype__c = 'StatusTracking__c' AND ( status__c = 'Archived' OR status__c = 'Failed To Archive' OR status__c = 'Failed To Delete Original' )) AND createddate < :olderThan ORDER BY createddate ASC
NOTE: ** queries all the records with the limit 10000 and moved the filtering to the execute() method, it was before in start() method and thrown the "First error: [REQUEST_RUNNING_TOO_LONG] Your request was running for too long, and has been stopped." error.