Hi All,
I have a weird query error, when querying the user object. The following query throws me an error.
SELECT IsActive,UserPermissionsKnowledgeUser,ContactId,CreatedById from User WHERE UserPermissionsKnowledgeUser = true and isActive = true.
The error says:
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).
Seems like this query needs an indexed filter in the where clause just because the User Object is too large. I have an external ID field I can use to filter, but that might impact the number of records returned. I only have like 20 records, but salesforce looking through all the rows to return 20 records sounds ridiculous.
Any work around or a fix to avoid this? Thanks in advance.
Thanks
Karthik.