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
mysteriousauramysteriousaura 

Sandbox throws a System.QueryException: Non-selective query exception after refresh

Hello All,

Everytime I refresh my sandbox, I start getting this error. Everything is fine in production and other sandboxes but for a new SB this is an issue.
Anybody have any ideas and faced similar issues?

Apex trigger processEnrollmentJSONFeed caused an unexpected exception, contact your administrator: processEnrollmentJSONFeed: execution of AfterInsert caused by: 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): Class.processJSONStage.processEnrollmentJSONStage: line 691, column 1

I try and create some external Id's and add conditions to my query .. sometimes it works and same code in another SB does not.
 
Niket SFNiket SF
Hi,
 I am asuming that you are having full copy sandbox. Everytime you refresh the Sandbox it copies the production data in to Sandbox. It Seems "processEnrollmentJSONFeed" having a query on a object where dataset is large because of Production data. You need to make sure the respective SOQL query should run on small set of data. Try to add more where clause in your query and try to filer via indexed fields.
mysteriousauramysteriousaura
Thanks for the reply. That would make sense but I am not talking about a full sandbox. Its just a regular empty sandbox which is the strange part. Do you have any other ideas?
Niket SFNiket SF
Regular sandbox can not have this much data. If you can add screen shot it will be helpful.
mysteriousauramysteriousaura
Here is the screenshot of the Data Space on the Sandbox.
User-added image

Here is the error i get when I try to insert data in a object that has a trigger which processes the JSON string. 

User-added image