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
nick8nick8 

I am getting System.QueryException: Non-selective query against large object type" this error

 Set<Id> OTCorpids = new Set<Id>();
        for(Order_Transaction__c OTlist : ots){
            OTCorpids.add(OTlist.Corp_Account__c);
            system.debug('OTCorpids***** '+OTCorpids);
        }
        
        Map<Id, List<Account>> corptogrpacctsmap = new Map<Id,List<Account>>();
        for(Account grpacct : [SELECT Id,Parentid,RecordTypeId FROM Account WHERE Parentid IN: OTCorpids AND Status__c = 'Active' order by recordtypeId]){// this is the line i am getting the error. 

I am not sure why

Thanks 
VamsiVamsi
Hello,

Hope this may help you 

https://help.salesforce.com/articleView?id=000002493&language=en_US&type=1

Please mark as best answer if the above helps ...!!
Amit Chaudhary 8Amit Chaudhary 8
try to remove oder by from query and try again
Please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_VLSQ.htm