You need to sign in to do that
Don't have an account?

Non-selective query against large object type (more than 100000 rows)
Ok so i have read other entries but nothing i take seems to be working so hopefully someone can look at my code and see what the issue is. Im getting these emails raipdly these days and even when going to clean up data im starting to see if on new records as well.
PrimaryAddressValidation: execution of BeforeUpdate
caused by: System.QueryException: Non-selective query against large object type (more than 100000 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)
Trigger.PrimaryAddressValidation: line 55, column 1
and this is my code the error is coming in at the fist List select statment in each if statement below.
PrimaryAddressValidation: execution of BeforeUpdate
caused by: System.QueryException: Non-selective query against large object type (more than 100000 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)
Trigger.PrimaryAddressValidation: line 55, column 1
and this is my code the error is coming in at the fist List select statment in each if statement below.
// section makes sure that only one checkbox is true within the related address list for the contact if(!contactIdsForShipping.isEmpty()) { List<ShipTo_Address__c> toggleShippings = shipToExcluded.isEmpty()? [SELECT Id, Default_Shipping_Address__c FROM ShipTo_Address__c WHERE Contact__c IN :contactIdsForShipping AND Default_Shipping_Address__c=true] : [SELECT Id, Default_Shipping_Address__c FROM ShipTo_Address__c WHERE Contact__c IN :contactIdsForShipping AND Default_Shipping_Address__c=true AND Id NOT IN :shipToExcluded]; for(ShipTo_Address__c a : toggleShippings) { a.Default_Shipping_Address__c = false; } update toggleShippings; } if(!contactIdsForBilling.isEmpty()) { List<ShipTo_Address__c> toggleBilling = billToExcluded.isEmpty()? [SELECT Id, Primary_Billing_Address__c FROM ShipTo_Address__c WHERE Contact__c IN :contactIdsForBilling AND Primary_Billing_Address__c=true] :[SELECT Id, Primary_Billing_Address__c FROM ShipTo_Address__c WHERE Contact__c IN :contactIdsForBilling AND Primary_Billing_Address__c=true AND Id NOT IN :billToExcluded]; for(ShipTo_Address__c a : toggleBilling) { a.Primary_Billing_Address__c = false; } update toggleBilling; } }
You should try make Contact__c as external Id field that would resove this error if you can't do that then you should try filtering out null from your query. you should do that for all your queries. Here is the same solved question: https://developer.salesforce.com/forums/?id=906F00000008vLPIAY
All Answers
You should try make Contact__c as external Id field that would resove this error if you can't do that then you should try filtering out null from your query. you should do that for all your queries. Here is the same solved question: https://developer.salesforce.com/forums/?id=906F00000008vLPIAY
Thanks Again your awesome....
Ivan