You need to sign in to do that
Don't have an account?
Rajiv B 3
caused by: System.QueryException: Non-selective query
Hi all ,
I am getting below error while change the Storage__C owner from X to Y.
caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Options to resolve error
1. You may find that the query in question needs to be more selective in the WHERE clause. According to the Salesforce standards & best practices - the where clause needs to subset 10% or less of the data.
2. A custom index on the field.
3. A possible quick fix may be to make the field in question an external ID. Since external IDs are indexed automatically, this will create the index and may solve the problem.
Appreciate your help
I am getting below error while change the Storage__C owner from X to Y.
caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
trigger StevContacts on Storage__C (after update) { List<Storage__C> Strs = [select Id, Type, (select Primary_Campaign__c from Contacts) from Storage__C where Id IN :Trigger.newMap.keySet()]; List<Contact> contacts = new List<Contact>(); Storage__C oldStrs; for(Storage__C s: Strs) { oldStrs = Trigger.oldMap.get(s.Id); if (oldStrs.Type != s.Type && s.Type == 'Stev') { for(Contact c: s.Contacts) { c.Primary_Campaign__c='Stev'; contacts.add(c); } } else if (oldStrs.Type != s.Type && oldStrs.Type == 'Stev') { for(Contact c: s.Contacts) { c.Primary_Campaign__c='ting'; contacts.add(c); } } update contacts; } }I have gone through documents . Found below below points but not able fiqure it out .. where exactly i have to do changes in my code.
Options to resolve error
1. You may find that the query in question needs to be more selective in the WHERE clause. According to the Salesforce standards & best practices - the where clause needs to subset 10% or less of the data.
2. A custom index on the field.
3. A possible quick fix may be to make the field in question an external ID. Since external IDs are indexed automatically, this will create the index and may solve the problem.
Appreciate your help
Change your code with below code before making any other changes. Don't forget to replace proper API name for fields.
Let me know if you face any other issues.
Regards
Naveen