You need to sign in to do that
Don't have an account?
developer03
Non-selective query problem
Hi,
I have created a trigger that will fire on Opportunity after update, insert and delete events. It will determine how many Opportunities are outstanding and update the associated account with the outstanding count.
This is the WHERE clause of the query:
((Opportunity.StageName = '5 - Offer by Client (Conditional)' OR Opportunity.StageName = '6 - Offer by Client (Unconditional)' OR Opportunity.StageName = '7 - Preliminary Accept' OR Opportunity.StageName = 'Deferred by Applicant') AND Opportunity.Course_Start_Date__c <= TODAY AND Opportunity.PSR__c = false AND Opportunity.InstituitionAccount__c = :accountId)
The problem is the following exception gets thrown:
System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
What does this mean? How can I avoid this problem?
I have created a trigger that will fire on Opportunity after update, insert and delete events. It will determine how many Opportunities are outstanding and update the associated account with the outstanding count.
This is the WHERE clause of the query:
((Opportunity.StageName = '5 - Offer by Client (Conditional)' OR Opportunity.StageName = '6 - Offer by Client (Unconditional)' OR Opportunity.StageName = '7 - Preliminary Accept' OR Opportunity.StageName = 'Deferred by Applicant') AND Opportunity.Course_Start_Date__c <= TODAY AND Opportunity.PSR__c = false AND Opportunity.InstituitionAccount__c = :accountId)
The problem is the following exception gets thrown:
System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
What does this mean? How can I avoid this problem?
The error seems to indicate that your query is going to select a lot of rows. Too many, in fact. Perhaps, we can track down why with a little more detail.
That is the complete query.
When I run this query in Apex Explorer I get at most 4 rows. Maybe the error is complaining Opportunity table has too many rows (it has 180,000 rows)?
Essentially trigger recieves (Trigger.new or Trigger.old) will be fully populated with data, but they won't include data from child/related objects. So if you try using child/relational value it will be null and hence non-selective query issue will be encountered.
I have been told with this upcoming 08 release attempting to read a data value that has not been queried from the DB will result in a runtime error. This will make this kind of issue much easier to diagnose.
Thanks.