I am using SOSL query in a method in Apex class.This method is getting called from trigger,when a custom object DCR
is created.
SOSL Query:
List<List<Account>> acclist = [FIND :newstring IN NAME FIELDS RETURNING Account(Id,FirstName,LastName,Territory_vod__c where RecordType.Name='Prescriber' ) ];
DCR
is having lookup with Account.newstring
is having string value.I am using SOSL (instead of SOQL) due to requirement.I cannot use any other indexed field in WHERE condition due to requirement constraint.
I am getting this error while creating DCR
record:
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):
What could be the workarounds for this exception?
WHERE
condition due to requirement constraint. – devsfdc Mar 7 '17 at 5:02