function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TehNrdTehNrd 

System.QueryException: Non-selective query against large object

I am encountering this error with the following query but I am not sure why. I thought non selective meant you didn't have a where clause but this query does.

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)


Code:
for(Opportunity opp : [select Id, Reseller_Company_Name__c, Partner_Level__c, Partner_Engagement_Type__c from Opportunity where Reseller_Company_Name__c IN :coNames AND LastModifiedDate >= :oldestDate]){
String resName = opp.Reseller_Company_Name__c;
Automation__c match = fuzzyNameMatch.get(resName);
opp.Reseller_Company_Name__c = match.Reseller_Company_Name__c;
oppsToUpdate.add(opp);
}


Thanks.


Message Edited by TehNrd on 10-21-2008 09:47 AM
SuperfellSuperfell
Most likely coNames contains a null value.
TehNrdTehNrd
I'll add some debug statements and report back.
TehNrdTehNrd
None of the collections contain null. I'm stumped.

Code:
System.debug('coNames: ' + coNames);
for(String s : coNames){
       system.debug('coName: ' + s);
}
system.debug('theaters: ' + theaters);
system.debug('oldestDate: ' + oldestDate);

for(Opportunity opp : [select Id, Reseller_Company_Name__c, Theater__c from Opportunity where Reseller_Company_Name__c != null AND Theater__c != null AND Reseller_Company_Name__c IN :coNames AND Theater__c IN :theaters AND LastModifiedDate >= :oldestDate]){
}
20081021233518.046:Trigger.resellerCleanUpAuto: line 15, column 13: SelectLoop:LIST:SOBJECT:Automation__c 20081021233518.046:Trigger.resellerCleanUpAuto: line 74, column 13: coNames: {Fishnet Ssecurity} 20081021233518.046:Trigger.resellerCleanUpAuto: line 75, column 13: SelectLoop:SET:String 20081021233518.046:Trigger.resellerCleanUpAuto: line 76, column 17: coName: Fishnet Ssecurity 20081021233518.046:Trigger.resellerCleanUpAuto: line 78, column 13: theaters: {NA} 20081021233518.046:Trigger.resellerCleanUpAuto: line 79, column 13: oldestDate: 2008-09-24 19:06:26 20081021233518.046:Trigger.resellerCleanUpAuto: line 81, column 13: SelectLoop:LIST:SOBJECT:Opportunity
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) Trigger.resellerCleanUpAuto: line 81, column 13



Message Edited by TehNrd on 10-21-2008 04:39 PM
TehNrdTehNrd
I've opened a case: Case# 02203723
Cool_DevloperCool_Devloper

Hi There, 

I am facing a similar issue :(

Did you get a reply to your case? In my query, the filter is on a lookup field. So, I can't even make it an ExternalId field!

 

Any ideas?

Many Thanks,

Cool_D 

TehNrdTehNrd

I never got a super clear answer on this and I can't recall if it was something I did or salesforce did to help the issue. I have found that I usually only get this error in triggers and if i run them asychronously (@future) I don't get this error.

 

Sorry I couldn't be more help.