I am working on a requirement and need to get more than 50000 records stored in a set. The scenario is I am having two object with parent to cheild relationship and there are different filter some satisfy on parent and some on child.I need to query parent and get child with parent satisfying the filter condition and then child query to get all satisfying filter condition . In the end I need to remove all the parent record from query one result which doesnt have the child present in query 2 result.
There is coming the 50000 records limit running both the query which is limiting me to download more than sufficient records Is ther any workaround :
Query 1 : results in parent with child with limit 50000
Query 2 : results in child with limit 1200 As child can have maximum 40 child
Want to increase the number of record increase so that to have maximum set id in RecIDFinal
if (query2.size() > 0) {
for (childobj childobj: query2) {
orRecID.add(childobj.id);
RecIDFinal.add(childobj.parentlookup__c); //Adding parent id
}
}
if (query1.size() > 0) {
for (parentobj parentobj: query1) {
RecIDFinal.add(parentobj.id); // Adding id
for (childobj childobj: ordRecord.relation__r) {
if (!orRecID.contains(childobj.id)) {
RecIDRemove.add(ordRecord.id); // removing id if child not matches
}
}
}
}
for (Id objId: RecIDFinal) {
if (RecIDRemove.contains(objId))
RecIDFinal.remove(objId);
}