1
Select Id, Field1_Id__c, Field2__c from CustomObject__c where Field1_Id__c =: STRING_CHARACTER_BLANK AND Field2__c IN: setOfIds

Getting the following error when a query as above is executed from a Trigger Handler. Field1_Id__c is an External Id and hence indexed.

Non-selective query against large object type (more than 200000 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)

1 Answer 1

4

If STRING_CHARACTER_BLANK is null or an empty String (which translates to null in the query), then this query is not selective. Null values are not indexed in an indexed field; in other words, you're violating the first "rule" outlined in the error:

The filter value includes null (for instance binding with a list that contains null)

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .