set<ID> conIDs = new set<Id>();
for (Time__c t : trigger.new)
{
if (t.Contact__c != null)
conIDs.add(t.Contact__c);
}
if (!conIDs.isEmpty())
{
for(Time__c t : [Select Id, Time_In_Hours__c, Total_Amount__c From Time__c Where Contact__c IN: conIDs and Contact__c != null])
{
..... do some processing here
}
}
Above is my code and the line:
for(Time__c t : [Select Id, Time_In_Hours__c, Total_Amount_c From Time_c Where Contact_c IN: conIDs and Contact_c != null])
is throwing error:
execution of AfterUpdate caused by: System.QueryException: 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)
The problem is how can I overcome this? I cannot make Matter__c lookup field an External Field as suggested here .... how can I process the records?
The Time__c object has more than 120,000 records in the org.