You need to sign in to do that
Don't have an account?
asadim2
Querying large tables
The following SOSL fails, even when re-written in SOQL or used in a query for-loop, when there are 100K+ Contacts in the org:
I know why it's failing but I don't know how to fix it! I can't split this into 2 queries/searches either because the where-clause is ORed which means I have no choice but to query with the custom non-indexed field.
Note that this SOSL only fails when ran in a trigger!
FIND :value1 IN ALL FIElDS RETURNING Contact(Id WHERE PKG__Field__c = :value2 OR (Lastname = :value3 OR Name = :value4))The error is: System.QueryException: Non-selective query against large object type (more than 100000 rows)
I know why it's failing but I don't know how to fix it! I can't split this into 2 queries/searches either because the where-clause is ORed which means I have no choice but to query with the custom non-indexed field.
Note that this SOSL only fails when ran in a trigger!
Otherwise, you're looking at limiting the result set in your trigger somehow, perhaps by applying filters on related accounts or contacts according to what you're trigger is currently iterating through.