+ Start a Discussion

How big can a Schedulable class instance be?

Hey Community!  I've got a class that implements Schedulable.  It has members that are lists of sObjects.  Sometimes these lists can be very large (thousands of records).  When I try to schedule these large instances, it fails, saying that the scheduled object is "too large".  I can't find anything that describes how large a Schedulable class instance can be.  Does anyone out there know?

Thanks in advance,

Glyn Anderson
Sr Developer / Systems Analyst | ClosedWon | closedwon.com
Certified Developer | Certified Advanced Administrator

The documentation doesn't appear to state what the maximum size is. However, it is reasonable to assume that they should be small (maybe only a few items of details). The scheduled class should either perform the query at the time of execution (not beforehand), or it should call a batchable class, which is better suited for handling larger amounts of data. You could probably pass it a set of ID values, and have the scheduled class query those records when it executes. Keep in mind that scheduled classes have to be stored in the database, and therefore should be kept as small as possible.

Thanks for answering.  Here's the problem:  The records I have are the records I want to put into the database - I can't query them when the Schedulable class runs.  I've got code that queries a set of records from the database and, based on those records, creates and updates a large number of other records - potentially too many to do DML in a single transaction.  My idea was to create a Schedulable class to spread the DML out over several transactions.  The class has all the records to be DML'ed.  When it runs it does as many records as it can (using Limits methods) and schedules itself again to do the remainder.  When it's done, it schedules a "continuation job".  This has worked with over 9,000 records, but failed with some larger number.  I'm not sure at what point the instance gets too big.

I have also considered breaking the DML into transaction-sized chunks and creating a batchable job for each chunk.  The Batchable class would take a list of sObjects in its constructor and the start method would return that list as the iterable for the batch.  I could then execute these Batchable instances with a scope size of 10,000 (or a value from Limits) and the execute method can do the DML.  This still has the potential for the Batchable instance to be "too big".

Another problem is that even if I knew how big a Schedulable/Batchable instance could be, is this the size in memory or the size as serialized for persistence in the database?  And then, how can I know how big my collection of sObjects is (in bytes or whatever, as opposed to # of records)?  Basically, how can I gaurantee that my Schedulable/Batchable instance is not too large?

Any thoughts would be very much appreciated!


Hi GlynA, 

I do have an issue with below code, can you please help me. The issue is i am not able to save the updated values to the save record id. And all the values of the same account are being displayed. Can you please help.

I do have values as below
User-added image

When i click on the Sort by, the top 5 Account Priorities should display in a separate page and should be editable. Once i do change the priority i should be able to Save. The values should change return to the previous page. Please find my code as below

Visual Force Page

<apex:page standardController="Account_Plan__c" extensions="accountprioritysort1" tabStyle="Account" id="thePage">
    <apex:form id="theForm" >
    	<apex:pageBlock title="Editing Top 5 Account Priorities" mode="edit">
            <apex:messages />
				<apex:pageBlockButtons location="top">
            		<apex:commandButton value="Update Top 5 Account Priorities" action="{!Save}"/>
                    <apex:commandButton value="Cancel" action="{!Cancel}"/>
				<apex:pageBlockTable value="{!acts}" var="item">
                    <apex:column value="{!item.Account_Priorities__c}"/>
                    <apex:column headervalue="# (Top 5 Priorities)">
                        <apex:inputField value="{!item.Field1__c}"/>

Apex Class Page

public with sharing class accountprioritysort1 {    
    public ApexPages.StandardController stdController {get; set;}
    public Account_Plan__c AccPri { get; set; }
    public list<Company_Priorities__c> acts { get; set; }
    //public list<Account_Plan__c> acts1 { get; set; }
    public accountprioritysort1 (ApexPages.StandardController stdController){
        System.debug('Is it in the Constructor');
        this.stdController = stdController;
        this.AccPri = (Account_Plan__c)this.stdController.getRecord();
	    //acts = [select Field1__c,Account_Priorities__c from Company_Priorities__c where id = :AccPri.id limit 5];
	    acts = [select Field1__c,Account_Priorities__c from Company_Priorities__c ORDER BY Field1__c ASC limit 20];
    public PageReference SaveAction(){
        try {
            update this.AccPri;
        	}catch (exception e){
            PageReference page = new PageReference('/apex/AccountPrioritySortSep12?id='+AccPri.id);
            return page;
    public PageReference CancelAction(){
			PageReference page = new PageReference('/apex/AccountPrioritySortSep12?id='+AccPri.id);
           	return page;

Can anyone please suggest.