I have batch which queries for record in a standard object which has 16 million of records. I am trying to query only few records with checkbox checked using querylocator to delete it .
However the query takes too long to process and times out.
The query used is "Select id, Delete_Social_Post__c,xxx_c,ExternalId_c, CreatedDate From SocialPost where Delete_Social_Post__c = true Order by createddate asc
"
Rgds
Best Answer
You can improve your performance with selecting indexed fields - you should read about performance patterns like this:
Improve performance with Custom indexes using Selective SOQL Queries