You need to sign in to do that
Don't have an account?

System.QueryException: Non-selective query against large object type (more than 100000 rows)
Hello Salesforce Gurus,
I need help with this exception: System.QueryException: Non-selective query against large object type (more than 100000 rows)
Following is the query where I get the exception: select Opportunity_Number__c,Id
from Opportunity where Opportunity_Number__c in :LstOpptyNbrs
Now Opportunity_Number__c is Text(255) (External ID) (Unique Case Sensitive). Salesforce suggests that if the dataset is large than the query should contain filters against indexed fields, which I am doing here. Moreover I get this exception when a record is sent from another SF instance in a SF - SF integration.
Thanks & Regards,
K
Querymore can help
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_querymore.htm
Thanks Avijit for your reponse, however the code that i posted is used in SOQL for loop, which internally uses QueryMore call.
check this: While the standard queries discussed in SOQL and SOSL Queries can retrieve either the count of a query or a number of object records, SOQL for loops retrieve all sObjects, using efficient chunking with calls to the query and queryMore methods of the SOAP API.
Moreover since the field is an external Id, there would be only one row for each value in the list used in the where clause.
Regards,
K
Salesforce.com Architect
Hi Chetan,
Can you explain a bit more about that? I thought that since the Opportunity_Number__c is a unique key/indexed, there would be only one opportunity for each Opportunity_Number__c. Moreover it won't do a full table scan when you use that field.
Thanks,
K
This doc wil help u:
http://www.salesforce.com/us/developer/docs/ldv/salesforce_large_data_volumes_bp.pdf