You need to sign in to do that
Don't have an account?
Non-selective query against large object type
Can someone please point me in the right direction?hanks.
Error Message: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)
Error System Trace: Class.HelperClass.newEval: line 982, column 1 Trigger.triggername: line 36, column 1
trigger triggername on Object__c (after insert, after update) { if(trigger.isInsert){ List<Object__c> evaluations = [Select Id From Object__c]; Map<Id, List<Id>> junk = new Map<Id, List<Id>>(); for (Object__c obj : evaluations) { junk.put(obj.Id, new List<Id>()); } for (Employee_Object__c empobs : Trigger.new) { if (junk.containsKey(empobs.Object__c)) { junk.get(empobs.Object__c).add(empobs.Id); } } HelperClass.newEval(trigger.new); // line36 } ...... }
public without sharing class HelperClass { public static void newEval(list<Object__c> newEV){ try { //Get List of Employee IDs, OS set<id> empIDs = new set<id>(); set<id> cnIds = new set<id>(); for(Object__c ev: newEV){ empIDs.add(ev.Employee__c); cnIDs.add(ev.Group_Leader_Id__c); } list<Employee__c> emps = [select id,Manager_Id__c,Group_Leader_Id__c,SC_ID__c from Employee__c where id in:empIDs]; map<id,Employee__c> mp_emps = new map<id,Employee__c>(emps); //Get User IDs from Contact for(Employee__c e: emps){ cnIds.add(e.Group_Leader_Id__c); cnIds.add(e.SC_ID__c); } list<user> usr = [select id, contactID from user where contactID in: cnIDs]; // line982 map<id,id> usrIDs = new map<id,id>(); //first ID is the Contact for(user u:usr){ usrIDs.put(u.contactID,u.id); } ....... }
Hi,
While working with very large SOQL series , query in for loop or use Apex Batch Class.
usrIDs.put(u.contactID,u.id);//ContactId is lookup and indexable
}
usrIDs.put(u.contactID,u.id);//ContactId is lookup and indexable
}
Thanks very much SaiKishore and Grazitti. Your suggestions are much appreciated.
I will test and let you know how I go..