Skip to main content

Hi, I get this error but the difference is that my SOQL queries actually return a value. I make sure they are  of size limit 1 or no greater than 4 in the ones which were flagged as errors. I have not deployed code in nearly 1.5 months , at 78% code coverage, and just last Thursday our SFDC Admin was attempting to deploy workflows using change sets and suddenly got 25 of these "Non-selective query" errors. None of the 25 errors have SQOL queries that  return Null because the queries use no variables  in the WHERE clause. Here is a sample of the SOQL code issues I am having: The "Non-Selective query" error occurs at the last query within this code segment. 

@isTest (seeAllData=true)

public class TestOpportunityAfterUpdate {

public static testmethod void TestAdvocacyShipCharge(){

AdvocacySupplyShipCharge_Test.TestAdvocacySupplyShipCharge();

}

public static testmethod void TestMozoAccounts(){

List<Opportunity> Orders = new List<Opportunity>();

Set<Id> contactIds = new Set<Id>();

List<Id> orgIds = new List<Id>();

User ouser = [SELECT Id from User where Name = 'Awana Applications' limit 1];

RecordType rec = [Select Id from RecordType where SObjectType = 'Opportunity' and Name = 'Orders'];

Map<Id,Opportunity> mozoMap = new Map<Id,Opportunity>();

List<Account> accts=[Select Id, Default_Shipping_Address__c, Mailing_Address_Book__c,Registration_Level__c, Registration_Status__c, Date_Inactive__c,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry

from Account WHERE RecordType.Name = 'US Organization' and Date_Inactive__c <> null and Account_On_Hold__c = false and RecordType.Name in ('Canada Church','US Organization') limit 4];

system.debug('<< ACCOUNTS>> '+accts);

for(Account acct : accts){

orgIds.add(acct.Id);

}

Here is the Production Workbench Query Result from the last query of the code above. Thanks much for your help.:

System.QueryException: Non-selective query against large object type (more than 100000 rows).
4 Antworten
  1. 29. Juli 2015, 17:54
    OK Shashikant, thanks let me get back to you after trying option ⌗ 2 that you gave me to see if that works.  There are 13 ftest classes that are coming up with this error and it may make it much slower to recode but I will update and then do a validation deployment to see if those errors still occur and let you know. Thanks
0/9000