I am loading contacts records and when my after insert triggers runs I am getting the following error:
System.QueryException: 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:
- The filter value includes null (for instance binding with a list that contains null)
- 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)
I have the debug log and this occurs when the following is happening
SELECT Id, OwnerId, LastName, AccountId, Email FROM Contact WHERE (Email = :tmpVar1 OR Personal_Email__c = :tmpVar2) LIMIT 1
When this runs it actually returns no rows, which is fine I am just not sure how I can solve this problem as I need to execute this query. I do know that there are over 200,000 records in total in the object.