You need to sign in to do that
Don't have an account?
CarlB
"Non-selective query against large object type" error
Hello.
I have a table containing over 270,000 objects. When I try to insert more objects, I get an error saying "Non-selective query against large object type" from a before-insert trigger that I have on that table.
The before-insert trigger is to prevent duplicate rows being inserted based on a formula field:
Thanks,
Carl
I have a table containing over 270,000 objects. When I try to insert more objects, I get an error saying "Non-selective query against large object type" from a before-insert trigger that I have on that table.
The before-insert trigger is to prevent duplicate rows being inserted based on a formula field:
trigger XBeforeInsert on X__c (before insert) { Map<String, X__c> xs = new Map<String, X__c>(); for (X__c x: Trigger.new) { xs.put (x.Unique__c, x); } for (X__c x: [ Select Id, Unique__c, RecordTypeId From X__c Where Unique__c in :xs.keySet()]) { // add some error message } }The field Unique__c is not indexed. Would getting Salesforce to add a custom index on that field make a difference? Alternatively, is there some other way to achieve this?
Thanks,
Carl
1.) You can add more filters in the query.
2.) You can contact support to get your field Unique__c custom indexed provided it matches the indexing criteria.That would certainly help.
If this helps,please mark it as best answer to ehlp others :)
Here is a query optimization cheet sheet. In the Related Resources section you'll find some articles that expand on the subject of selective queries.
http://help.salesforce.com/help/pdfs/en/salesforce_query_search_optimization_developer_cheatsheet.pdf