0

I was working months with my class, but now give me the following error:

"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) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)"

In this Line:

usuarios=[select id,PersonEmail,marca__c,
        Marcas_de_las_que_quiere_recibir_ofertas__c,dni__c,
        Segmento__c,Datos_Preferencias__c,
        Datos_Test_Compatibilidad__c,Datos_Test_Big_Five__c,
        Datos_CV_Obligatorio__c, datos_contratacion__c,
        Fecha_orientacion_a_marca__c,Resultado_orientacion_a_marca__c,
        Fecha_formacion_online__c,Resultado_formacion_online__c
              from Account
              where 
              Segmento__c in :setsegmentos
              and Marca_relacional__c in: listaMarcas
              and Baja__c=false and Ya_estoy_trabajando__c=false 
              and  Back_list__c=false 
              and Inactivo__c=false limit 3000];

My SOQL just take 3000 records. Anyone can help me please?

I made some change for an advice fromm chri (thank you!), but still the same error.

  • I see you are doing a <> null check, this makes your query fall in to the non selective index category. If you look at [link](https://developer.salesforce.com/blogs/engineering/2013/02/force-com-soql-best-practices-nulls-and-formula-fields.html) you see that doing this type of query results in a full table scan. You can work with salesforce to build an index on that field to include null values, or re work your soql query, have a look at this [link](https://help.salesforce.com/help/pdfs/en/salesforce_query_search_optimization_developer_cheatsheet.pdf) to make your query more selective – chri Feb 03 '15 at 10:17
  • Hello chri, thank you for your response, I made some changes in code, now I have just an lookup, a set with ID's, and boolean field in where clause, but still not working. :/ – Guillermo Ramos Feb 05 '15 at 09:43
  • Hi. Can you paste your query here? I don't think boolean fields cut the mustard either. What I have done in the past is copy the boolean fields to a text field(updated via workflow). Make sure the text field is an external ID. The values itself can be something like 'Y' for true and 'N' for false. – chri Feb 12 '15 at 16:20

0 Answers0