Search code examples
salesforceapex-codesoql

Maximum Size of List in APEX Salesforce


I have created a DataBase.Batchable class in which I am inserting a custom object named Event__c

public class BatchCreateGCalendars implements Database.Batchable<SObject>, Database.Stateful, Database.AllowsCallouts {
 private List<Event__c> event_id;
}

I am creating, for example, 1000 records of type events and then using the statement

insert event_id;

Is this good, or is inserting each element one by one more appropriate? In my custom object I created only one custom field of type text(255), what is the maximum size of a list?


Solution

  • There's not a defined limit for size of a list. I think the limit you'd eventually hit is heap size, which is currently 12 MB for a batch job. However, you need to be mindful of the number of records you can process via DML, which is currently 10,000.