You need to sign in to do that
Don't have an account?
Non-selective query against large object type (more than 100000 rows). Consider an indexed filter.
Hello all,
I am getting the error below in my Lead trigger:
Non-selective query against large object type (more than 100000 rows). Consider an indexed filter.
I am guessing my SOQL query in the list is returning too many results. It is:
List<CampaignMember> listCampaignMember = [Select Id,CampaignId,LeadId From CampaignMember Where LeadId IN:setLeadId];
I have read that a solution involves making one of the CampaignMember fields an "External ID" but don't know which one to do this for.
Any ideas on how to optimize my SOQL query or what field I should make an External ID on the CampaignMember object?
Thanks!
Make sure you filter you query for less number of records
or you can call salesforce for indexing a particular field
try this:
Lead[] l = [Select ID, (Select ID, CampaignID, LeadID From CampaignMembers) From Lead Where ID In :leadIDs];
Then to access the CampaignMember records
For(Lead ld : l){
for(CampaignMember cm : ld.CampaignMembers){
//do work here
}
}
Other use SOSL in case like this