We have scheduled a batch apex for deleteing 400K records daily intially it was worked fine but from last few days that batch job is terminating by giving this error

First error:

SQLException [common.exception.SfdcSqlException: ORA-01013: user requested cancel of current operation select /ApexBatch.Class.PlanDeleteBatch.start: line 33/ * from (select * from (select t.custom_entity_data_id "Id" from (select /*+ ...

I have raised a ticket with salesforce.com also but no luck. Can any one help on this?

Here is my code:

Batch Class:

global class PlanDeleteBatch implements Database.batchable<SObject>{

   global Database.QueryLocator start(Database.batchableContext info){
       String query;
       if(Test.isRunningTest()) {
           query = ('SELECT Id FROM data__c');
       } else {
           query = ('SELECT Id FROM data__c' );
       return Database.getQueryLocator(query); /* <-- error throwing here in error message */

   global void execute(Database.batchableContext info, List<data__c> scope) {
       delete scope;

   global void finish(Database.batchableContext info){   }

This is clearing the recycle bin operation.

After clearing the recycle bin also it is giving the same error again.

  • What's the chunk size set to when you are calling Database.executeBatch? – bigassforce Jan 2 '14 at 8:19

It looks like this is a bad error message - according to this knowledge article:


the underlying problem is that your query was aborted because it took longer than 2 minutes to complete.

There's some good advice (and links) regarding query optimisation at:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.