+ Start a Discussion
kkr.devkkr.dev 

System.QueryException: Non-selective query against large object type (more than 100000 rows).

I am getting  this error  System.QueryException: Non-selective query against large object type (more than 100000 rows).  only in production

Here is the query in my trigger.

 

list<Contact> con = new list<Contact>([Select c.Phone, c.EmpID__c, c.Id, c.Email From Contact c where c.EmpID__c!=null and c.EmpID__c =: trigger.new[0].ID__c limit 1])

 

Thanks

 

MattLacey.ax1065MattLacey.ax1065

If the field ID__c on the first record is null, you'll be pulling all the records where that field is null. Chances are you have a lot of these on production if it's a new field!

 

Modify the code to skip your logic if trigger.new[0].ID__c is null.

 

Alternatively, trigger.new[0].ID__c has a value, but it's a value that 10,000+ other contacts have as well, though I think you're probably just dealing with nulll here!