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

Is there a way to write a test class to to test 'Non-selective query against large object type'
Hello - I need to test the below query. Is there a way to test for this specific exception in a test class? 'Non-selective query against large object type'
existingLead = [SELECT Id, street, LastName, PostalCode, LastNameStreetAndZipCode__c, Core_Number_Text__c, Status, Home_Phone__c, CreatedDate, Core_Number__c, Policy_Core_Number__c, Lead_Type__c
FROM LEAD
WHERE ((LastNameStreetAndZipCode__c IN :lastNameStreetZipSet
AND Core_Number__c IN :coreNumberTextSet)
OR (LastNameStreetAndZipCode__c IN :lastNameStreetZipSet)
OR (LastNameStreetAndZipCode__c IN :setOfPoBoxes))
AND Household__c != null
AND Duplicate__c != True
AND IsDeleted = False
ORDER BY CreatedDate ASC
LIMIT 20000];
existingLead = [SELECT Id, street, LastName, PostalCode, LastNameStreetAndZipCode__c, Core_Number_Text__c, Status, Home_Phone__c, CreatedDate, Core_Number__c, Policy_Core_Number__c, Lead_Type__c
FROM LEAD
WHERE ((LastNameStreetAndZipCode__c IN :lastNameStreetZipSet
AND Core_Number__c IN :coreNumberTextSet)
OR (LastNameStreetAndZipCode__c IN :lastNameStreetZipSet)
OR (LastNameStreetAndZipCode__c IN :setOfPoBoxes))
AND Household__c != null
AND Duplicate__c != True
AND IsDeleted = False
ORDER BY CreatedDate ASC
LIMIT 20000];
I have not tried myself but you might want to create more than 200,000 records to test this behaviour.Also recommend reviewing https://salesforce.stackexchange.com/questions/194897/system-queryexception-non-selective-query-against-large-object-type-more-than
If this information helps, please mark the answer as best. Thank you