+ Start a Discussion

Non-selective query against large object type (more than 100000 rows)

this is my code:

List<string> flstImport = new List<string>();

//add items to flstImport

List<InventoryCheckItem__c> flstInventoryCheckItem = [Select i.ImportId__c, i.Id From InventoryCheckItem__c i where i.ImportId__c in : flstImport];

it works well in sandbox, when deploy, i get the error message:

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)


1.there are 402965 records in table InventoryCheckItem__c.
2.i already set ImportId__c "external ID"

My English is very poor, who can help me!~~~~~

make sure flstImport doesn't contain any null values.
thank you, SimonF


■flstImport■(9999999991022722009-1, 9999999991022722009-2);

but table "InventoryCheckItem__c" exist records where ImportId__c is null

is this the reason?

Best Regards
In order for your external ID field to be an effective index, it should be non-null and unique, as a true keyed index would be.
thank you, i will try it again.