How to process more than 25 batches of 2000 records?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I am trying to chunk the results of a query of mine, but I am noticing the batches stop after 50,000 records (25 batches of 2000 records). I read iterable has a limit of 50,000 but I thought that was 50,000 records per batch.
What are my options for being able to query and process all of my case records when recordtype 000 has over 50,000 records and record type 111 has over 50,000 records?
Execute Anonymous:
Database.executeBatch(new batchClassExample(), 2000);
Batch Class:
global class batchClassExample implements Database.Batchable < Case >
List < string > exampleRecordTypeIds = new List < string > ();
global batchClassExample()
string exampleRecordTypeIdString = '000XXX000XXX, 111XXX111XXX';
exampleRecordTypeIdString = exampleRecordTypeIdString.deleteWhitespace();
exampleRecordTypeIds = exampleRecordTypeIdString.split(',');
global Iterable < Case > start(Database.BatchableContext BC)
Integer count = Limits.getLimitQueryRows() - Limits.getQueryRows();
return [select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds LIMIT: count
];
global void execute(Database.BatchableContext BC,
List < Case > scope)
for (integer s = 0; s < scope.size(); s++)
system.debug(scope[s]);
global void finish(Database.BatchableContext BC)
apex batch case limits
add a comment |Â
up vote
1
down vote
favorite
I am trying to chunk the results of a query of mine, but I am noticing the batches stop after 50,000 records (25 batches of 2000 records). I read iterable has a limit of 50,000 but I thought that was 50,000 records per batch.
What are my options for being able to query and process all of my case records when recordtype 000 has over 50,000 records and record type 111 has over 50,000 records?
Execute Anonymous:
Database.executeBatch(new batchClassExample(), 2000);
Batch Class:
global class batchClassExample implements Database.Batchable < Case >
List < string > exampleRecordTypeIds = new List < string > ();
global batchClassExample()
string exampleRecordTypeIdString = '000XXX000XXX, 111XXX111XXX';
exampleRecordTypeIdString = exampleRecordTypeIdString.deleteWhitespace();
exampleRecordTypeIds = exampleRecordTypeIdString.split(',');
global Iterable < Case > start(Database.BatchableContext BC)
Integer count = Limits.getLimitQueryRows() - Limits.getQueryRows();
return [select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds LIMIT: count
];
global void execute(Database.BatchableContext BC,
List < Case > scope)
for (integer s = 0; s < scope.size(); s++)
system.debug(scope[s]);
global void finish(Database.BatchableContext BC)
apex batch case limits
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to chunk the results of a query of mine, but I am noticing the batches stop after 50,000 records (25 batches of 2000 records). I read iterable has a limit of 50,000 but I thought that was 50,000 records per batch.
What are my options for being able to query and process all of my case records when recordtype 000 has over 50,000 records and record type 111 has over 50,000 records?
Execute Anonymous:
Database.executeBatch(new batchClassExample(), 2000);
Batch Class:
global class batchClassExample implements Database.Batchable < Case >
List < string > exampleRecordTypeIds = new List < string > ();
global batchClassExample()
string exampleRecordTypeIdString = '000XXX000XXX, 111XXX111XXX';
exampleRecordTypeIdString = exampleRecordTypeIdString.deleteWhitespace();
exampleRecordTypeIds = exampleRecordTypeIdString.split(',');
global Iterable < Case > start(Database.BatchableContext BC)
Integer count = Limits.getLimitQueryRows() - Limits.getQueryRows();
return [select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds LIMIT: count
];
global void execute(Database.BatchableContext BC,
List < Case > scope)
for (integer s = 0; s < scope.size(); s++)
system.debug(scope[s]);
global void finish(Database.BatchableContext BC)
apex batch case limits
I am trying to chunk the results of a query of mine, but I am noticing the batches stop after 50,000 records (25 batches of 2000 records). I read iterable has a limit of 50,000 but I thought that was 50,000 records per batch.
What are my options for being able to query and process all of my case records when recordtype 000 has over 50,000 records and record type 111 has over 50,000 records?
Execute Anonymous:
Database.executeBatch(new batchClassExample(), 2000);
Batch Class:
global class batchClassExample implements Database.Batchable < Case >
List < string > exampleRecordTypeIds = new List < string > ();
global batchClassExample()
string exampleRecordTypeIdString = '000XXX000XXX, 111XXX111XXX';
exampleRecordTypeIdString = exampleRecordTypeIdString.deleteWhitespace();
exampleRecordTypeIds = exampleRecordTypeIdString.split(',');
global Iterable < Case > start(Database.BatchableContext BC)
Integer count = Limits.getLimitQueryRows() - Limits.getQueryRows();
return [select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds LIMIT: count
];
global void execute(Database.BatchableContext BC,
List < Case > scope)
for (integer s = 0; s < scope.size(); s++)
system.debug(scope[s]);
global void finish(Database.BatchableContext BC)
apex batch case limits
asked Aug 22 at 21:23
S.B.
3069
3069
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
Your start method is limited to 50,000 SOQL rows, except for your Database.QueryLocator, if you choose to use one. To get past this limit, use a Database.QueryLocator:
return (Iterable<Case>)Database.getQueryLocator([
select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds
]);
add a comment |Â
up vote
3
down vote
A batch can process up to 50 million records. Based on documentation
, I think you may want to change your code in the following ways:
Create a global string variable, call it "queryString" for example - which holds the query for both recordtypes (I.E 'Where RecordTypeId IN: recordTypeIds')
Change the start() method to return type DataBase.queryLocator, and within the start method call Database.queryLocator(queryString).
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Your start method is limited to 50,000 SOQL rows, except for your Database.QueryLocator, if you choose to use one. To get past this limit, use a Database.QueryLocator:
return (Iterable<Case>)Database.getQueryLocator([
select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds
]);
add a comment |Â
up vote
4
down vote
accepted
Your start method is limited to 50,000 SOQL rows, except for your Database.QueryLocator, if you choose to use one. To get past this limit, use a Database.QueryLocator:
return (Iterable<Case>)Database.getQueryLocator([
select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds
]);
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Your start method is limited to 50,000 SOQL rows, except for your Database.QueryLocator, if you choose to use one. To get past this limit, use a Database.QueryLocator:
return (Iterable<Case>)Database.getQueryLocator([
select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds
]);
Your start method is limited to 50,000 SOQL rows, except for your Database.QueryLocator, if you choose to use one. To get past this limit, use a Database.QueryLocator:
return (Iterable<Case>)Database.getQueryLocator([
select Id, Owner.Id from case where RecordType.Id = :exampleRecordTypeIds
]);
answered Aug 22 at 21:31
sfdcfox
225k10171384
225k10171384
add a comment |Â
add a comment |Â
up vote
3
down vote
A batch can process up to 50 million records. Based on documentation
, I think you may want to change your code in the following ways:
Create a global string variable, call it "queryString" for example - which holds the query for both recordtypes (I.E 'Where RecordTypeId IN: recordTypeIds')
Change the start() method to return type DataBase.queryLocator, and within the start method call Database.queryLocator(queryString).
add a comment |Â
up vote
3
down vote
A batch can process up to 50 million records. Based on documentation
, I think you may want to change your code in the following ways:
Create a global string variable, call it "queryString" for example - which holds the query for both recordtypes (I.E 'Where RecordTypeId IN: recordTypeIds')
Change the start() method to return type DataBase.queryLocator, and within the start method call Database.queryLocator(queryString).
add a comment |Â
up vote
3
down vote
up vote
3
down vote
A batch can process up to 50 million records. Based on documentation
, I think you may want to change your code in the following ways:
Create a global string variable, call it "queryString" for example - which holds the query for both recordtypes (I.E 'Where RecordTypeId IN: recordTypeIds')
Change the start() method to return type DataBase.queryLocator, and within the start method call Database.queryLocator(queryString).
A batch can process up to 50 million records. Based on documentation
, I think you may want to change your code in the following ways:
Create a global string variable, call it "queryString" for example - which holds the query for both recordtypes (I.E 'Where RecordTypeId IN: recordTypeIds')
Change the start() method to return type DataBase.queryLocator, and within the start method call Database.queryLocator(queryString).
answered Aug 22 at 21:38
kabdelr00
404
404
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f229818%2fhow-to-process-more-than-25-batches-of-2000-records%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password