Total Pageviews

Sunday, March 22, 2015

Non-selective query against large object type (Issue)


In life many times simple things pose to be more nagging. Thinking of it why would salesforce be any different? In a age of "Lighting" , "Heroku" and "Mobility" there are minor things on the salesforce platform which might test our nerves. One such trifling issue is getting errors of non-selective query against large objects . We keep raking our heads why it keeps coming (as our memory is not always reliable that we had encountered it earlier too).

Error encountered : System.QueryException: Non-selective query against large object type (more than 100000 rows).
Lets ponder on this a bit!

What is a selective Query as against non-selective query?
A query is selective when one of the query filters is on an indexed field and the query filter reduces the resulting number of rows below a system-defined threshold. The performance of the SOQL query improves when two or more filters used in the WHERE clause meet the mentioned conditions.
What is Large Object Type?
Object having records in excess of 99999

Solutions
  • Consider an indexed filter
  • Contact salesforce.com about custom indexing.
One will need indexes for all of the fields one is using if SOQL . This means that fields in filter must all be marked as External ID or have custom indexes created.

Failing that, one may want to use SOSL, because the search indexer (not to be confused with a database index) will include all of the filter fields in the search.





No comments:

Post a Comment