我有 500 个地区要耕耘,还有 50 万个联系人。我尝试了一个 group by,但无法正常工作。如何避免遇到 soql 查询和返回行数的调控器限制?
public with sharing class Test {
public static void test() {
List <_Territory__c> terrsWithAee = [select id,name, Aee_Territory__c from _Territory__c where Aee_Territory__c != null];
String s = ' t.test Terrs with Aee = ' + terrsWithAee.size() + '\n';
for (_Territory__c t :terrsWithAee) {
Integer err = [select count() from contact where (Contact_AML_Territory__c = :t.id AND BDW_AML_Territory__c != :t.Aee_Territory__c ) OR (Contact_ChoicePlus_Territory__c = :t.id AND BDW_CP_Territory__c != :t.Aee_Territory__c)];
s = 'For Terr '+ t.id + ' errors= ' + err + ' terr name = \n' ;
}
}
}