Skip to content

Instantly share code, notes, and snippets.

@kiran-machhewar
Last active July 4, 2018 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiran-machhewar/cc6f0fd0d9e8d45ac34ceb5656c055e4 to your computer and use it in GitHub Desktop.
Save kiran-machhewar/cc6f0fd0d9e8d45ac34ceb5656c055e4 to your computer and use it in GitHub Desktop.
Analysis on Async Queues - SOQL, kill Async Jobs
****** BEGIN --> APEX CLASS wise distribution *****
SELECT ApexClass.Name, COUNT(ID) FROM AsyncApexJob WHERE Status = 'Queued' GROUP BY ApexClass.Name ORDER BY COUNT(ID) DESC
****** END --> APEX CLASS wise distribution *****
****** BEGIN --> Kill Async Jobs *****
for ( AsyncApexJob aJob : [ Select id ,Status, ApexClass.Name
from AsyncApexJob where Status='Queued' AND ApexClass.Name ='<ApexClassName>' LIMIT 150] ){
System.AbortJob(aJob.Id);
}
****** BEGIN --> Kill Async Jobs *****
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment