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
murali krishna.ax1501murali krishna.ax1501 

StandardSetController problem ,help me

I am getting this error for below StandardSetController code

 

14:28:20.105 (105857000)|EXCEPTION_THROWN|[13]|System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.

Even if a field is indexed a filter might still not be selective when:

1. The filter value includes null (for instance binding with a list that contains null)

 

 

//////-----------------------------------------------------------------------------------------

public class duplicateSMSFinder{

 public static string processNo;

 public ApexPages.StandardSetController setCon {
 
        get {
                  
              if(setCon == null && processNo !=null)
                {
                try{
                      system.debug(processNo+'ddddddddd');
                      setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,
                                                    Email,
                                                    Customer_Mobile__c,
                                                    Mobile_Number__c from
                                                    lead where
                                                       Customer_Mobile__c=:processNo limit 1]));
                      
                   }catch(exception e){}  
                      
                }//if
               
            return setCon;
        }     
        set;
    }//construcor

    // Initialize setCon and return a list of records
    
    public List<lead> getleadLists(string pSMSNO) {
    processNo=pSMSNO;
     if(setCon != null){
     return (List<lead>)setCon.getRecords();    
     }
     else{return null;}
    
    }
                
} //end of class

 

//////-----------------------------------------------------------------------------------------

Hengky IlawanHengky Ilawan

Hi,

 

Try to limit the result set that needs to be evaluated by adding " Customer_Mobile__c <> NULL" to the query WHERE string.

 

SELECT id, 
	Email, Customer_Mobile__c,
	Mobile_Number__c 
FROM Lead
WHERE
	Customer_Mobile__c <> NULL
	AND Customer_Mobile__c=:processNo 
LIMIT 1

 

I didn't try it though, but it might help. 

 

Or you can use SOSL instead of SOQL.

 

Let me know if it works.

 

Regards,

Hengky

murali krishna.ax1501murali krishna.ax1501

Thanks

I have used SOSL