Is anyone else seeing an increase in non-selective query errors recently? I've been seeing them a lot over the past few weeks, in various instances, in places where they weren't happening before, without obvious recent cause.

What takes the cake is we're currently getting a consistent non-seletive query err in a recently-burned Developer Pro sandbox. There's very very little data in here, probably less than 100 records total across all objects. Here's the storage in that sandbox:

enter image description here

Is there any legitimate reason why we'd be hitting a non-selective query err in this instance, regardless of what query is being run?

This seems to not happen in unit tests, only when inserting a record "for real" in the sandbox, via the web UI.

I'm submitting a case to SF support as well, but thought I'd check if anyone else is seeing this kinda thing.

2 Answers 2


To avoid "Query Error: "System.QueryException: Non-selective query against large object type"" exception, follow the below steps

  1. Make sure that your SOQL doesn't have null values in set or list or in a variable while fetching.
  2. Add Field_Name != null to avoid fetching null values records.
  3. Avoid using Formula field for filtering in SOQL.

Whenever an object has greater than 100K records any query on that object must be “selective”. For a query to be selective it must have enough indexed filters (where clauses) so that less than 10% of the records (in our example 10K) are returned before applying the limit statement. But u had less records means some problem in apex code or in trigger check for error.

  • Thanks for your reply, but did you read the part about this being a sandbox with very few records in it. I know in general about how data skew limits work, I just don't see how that applies here.
    – mscholtz
    Aug 4, 2014 at 7:28

If you find answer to this problem will you please post as I too am having same issue with recently refreshed (today) dev sandbox. I have one record in the Object. If I perform identical query in Dev Console it pulls record - no issues. Thanks.

  • This should be added as a comment, not as an answer
    – cropredy
    Aug 4, 2014 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .