Print this page

Error message, "System.QueryException: Non-selective query against large object type"

Knowledge Article Number 000002493

If you're running a trigger on objects that have more than 100,00 records, it's possible that you'll receive the error, "System.QueryException: Non-selective query against large object type." We'll go over the a few possible fixes. 


Options to resolve error

1. You may find that the query in question needs to be more selective in the WHERE clause. According to the Salesforce standards & best practices - the where clause needs to subset 10% or less of the data.

2. A custom index on the field.

3. A possible quick fix may be to make the field in question an external ID. Since external IDs are indexed automatically, this will create the index and may solve the problem.

A. Go to Setup.
B. Under "Build", click Customize then click the object name.
C. Click Fields.
D. Then, edit field name and check the box External ID.

promote demote