function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rob P12Rob P12 

System.QueryException: Non-Selective against large Oject type 10000K Records

System.QueryException: Non-Selective against large Oject type

This in a Before Update Trigger: on Opportunity

The Marketplace_Partner_Key__c is a field on the Account Object and the Opportunity. This field is passed from an external source who omitted the Account.Id. Therefore what I am trying to do is get to the the Account Object
using the Marketplace_Partner_Key__c on the Opportunity. This is not an indexed field so I'm trying to load only those Account Records where the Marketplace_Partner_Key__c is not null.

Here is the code that raises the error message:

    Set<Id> idSet = New Set<Id>();

    For (account tmp : [Select Id, Name, Marketplace_Partner_Key__c
        From account Where Marketplace_Partner_Key__c != Null
        Order by Marketplace_Partner_Key__c]) {
       
        
        if (tmp.Marketplace_Partner_Key__C != Null) {
            idset.add(tmp.Marketplace_Partner_Key__c);
           
         }
        
    }    
    

Thanks for any help