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
Dolly BasantaniDolly Basantani 

Visual workflow error : Non-selective query against large object type.

Hi,

I am trying to run a flow tha has to retrieve the accounts as a dynamic choice based on the filter i.e. domain name for the account.
after entering the email address, i query the account object and retrive the corresponding matched accounts with same domain name as a dynamic choice.
so whenever i try to select the option from the list retrieved and do next, it doesnot allows me to move on to the next screen saying "please select a choice".

when i traced the debug log it throws 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)"

I tried different filters still i am stuck.

Please help me on the same.

Thanks,
Dolly
ShashForceShashForce
Hi Dolly,

Are you filtering on null values in your SOQL query? Also, any query which returns more than 10% of the total records will be considered as 'non-selective'. If you run a non-selective query on an object which has more than 100000 records, you will see this error. You should include indexed fields in the WHERE clause to avoid these exceptions. To index fields, you can either mark those fields as 'External ID', or if that is not possible, you can contact salesforce support by creating a support case to create custom indexes on your fields based on your query.

Hope this helps :)

Thanks,
Shashank
Ramu_SFDCRamu_SFDC
The below post has the same discussion and some insights by various users. See if this helps

https://success.salesforce.com/answers?id=90630000000gqHaAAI
Dolly BasantaniDolly Basantani
Hi shashank,

I am not filtering on null values, infact i tried to use the indexed fields as a filter i.e Account Record type since it was suggested in some discussion forums but still not gettting rid of that exception :(