Query Issue

84 views
Skip to first unread message

Karthik

unread,
May 29, 2013, 8:07:18 PM5/29/13
to salesforce-p...@googlegroups.com
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.

Kalyan Kuchi

unread,
May 29, 2013, 9:24:09 PM5/29/13
to salesforce-p...@googlegroups.com
It's been a while I saw this but putting this in batch class might help

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "salesforce professionals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salesforce-profess...@googlegroups.com.
To post to this group, send email to salesforce-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/salesforce-professionals?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Narasimha

unread,
May 29, 2013, 11:45:21 PM5/29/13
to salesforce-p...@googlegroups.com
add where id != null to your query.

RB Chowdary

unread,
May 30, 2013, 1:25:05 AM5/30/13
to salesforce-p...@googlegroups.com
Hi Karthik,
When you're querying a Object and that has more than one lack records. Then you need to use Indexed Fields in where clause of Query.
Find the below link, it can help you.
Thanks & Regards.
Ravindra Babu Nagaboina


Salesforce.com Certified Force.com Developer
Hyderabad
Reply all
Reply to author
Forward
0 new messages