- I have a object(
Foo__c) with two columns(
Type__cis a picklist, with two options(
Value__cis a text field.
- Running into Non-Selective query error when running query like
SELECT Value__c FROM Foo__c WHERE Type__c = 'A' LIMIT 1in after update trigger on Contact object.
So, I looked into the Make SOQL query selective article and came up with the below calculation.
Query 1:(Total number of records in Object)
SELECT COUNT(Id) FROM Foo__c
Query 2:(Total number of records present in object where
Type__c = 'A')
SELECT COUNT(Id) FROM Foo__c WHERE Type__c = 'A'
Query 3: (Total number of records present in object where
Type__c = 'B')
SELECT COUNT(Id) FROM Foo__c WHERE Type__c = 'B'
Maximum number of records Query 2 or Query 3 can return before the query is considered non-selective is 127,552, Is that right?
//Applying 10% of first one million and 5% of remaining records (0.1*1000000)+((1551449-1000000)*0.05) = 127,552
That means, if I make
Type__c field indexed, it won't solve my non-selective query errors that I am running into in trigger context (for query 2 and 3), right?
I am going through Make SOQL query selective but still want to make sure that what I am interpreting is correct.
NOTE: I ran Query 2 and 3 using Bulk API