Skip to main content

Questions tagged [selectivity]

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

Query Plan: Cost of querying on Id is over 8

I have a query like this: SELECT Id FROM Visit WHERE Id = 'xxx' The Query Plan result looks like below, does anybody have any idea on this?
TCG's user avatar
  • 141
3 votes
1 answer
170 views

Non-selective query against large object type (more than 200000 rows) - Solution

Below is my query which throws the exception and is used in the trigger handler SELECT Id, RecordTypeId, Status, customObj1__c FROM Case WHERE customObj1__c IN : customObj1_Ids AND RecordTypeId IN : ...
Sooraj57's user avatar
2 votes
1 answer
490 views

Does sharing affect query selectivity?

I don't currently have an org with sufficient data to test this, and I've not been able to find a definitive answer so far. Would a with sharing declaration on an Apex class affect the selectivity of ...
dyson's user avatar
  • 257
11 votes
2 answers
1k views

SOQL query selectivity changes with number of IN clause records

I have a custom object with a Master-Detail relationship to Opportunity. The relationship field to the parent Opportunity is automatically indexed. There are 200,000 plus of these custom objects in ...
Daniel Ballinger's user avatar
3 votes
1 answer
268 views

selectivity threshold + OR condition in where clause

I'm facing trouble in understanding salesforce documentation, about selectivity threshold if SOQL uses two fields in where clause with 'OR' Condition. For e.g. Select id from account where FieldA = ...
curious_techy's user avatar
0 votes
2 answers
1k views

Data skew exists whereby the number of matching rows is very large

I am getting the following Error. works fine in DEV org but throwing error in UAT. Please suggest me as I was unable to move forward. The Actual Error is The first validation error encountered was ...
Muzeeb's user avatar
  • 3
1 vote
1 answer
439 views

SOQL and Indexes

I am trying to understand more about "SOQL Query Performance" topic and I'm reading all the Salesforce docs. I have a doubt when we have a WHERE clause with an AND condition. The two docs on this ...
vt89's user avatar
  • 725
2 votes
0 answers
86 views

Non-selective query against large object type (more than 200000 rows) -for querying with id

I am getting the below error in the trigger on Update: Non-selective query against large object type (more than 200000 rows) -for querying with id Query select id ,Calendar__c, (select id from ...
SF Learner's user avatar
  • 1,037
1 vote
1 answer
57 views

Is this a selective SOQL?

Select Id, Field1_Id__c, Field2__c from CustomObject__c where Field1_Id__c =: STRING_CHARACTER_BLANK AND Field2__c IN: setOfIds Getting the following error when a query as above is executed from a ...
nverm's user avatar
  • 199
-3 votes
1 answer
605 views

How to run SOQL for an Object having more than 200K records?

I’m trying to populate a custom lookup field called Part Name( API Name: Part_Number__c) on Case Object, where Part Name field is a lookup to Product Object( Maps to Product Name). We’ve 3 Picklist ...
sfdcDev's user avatar
  • 21
2 votes
3 answers
694 views

Non-selective query against large object type error when querying task

I have a bit of code in production that was working for about 3 days, then started failing with the old 'Non-selective query against large object type (more than 200000 rows)'. Here's the query: ...
Philip Clark's user avatar
2 votes
0 answers
139 views

Intermittent non-selective query

tl;dr: I believe that my particular query is selective, but Salesforce occasionally insists it isn't. Evidence follows. What am I missing? ==== Every now and again (7-8 occurrences since 2017-1-1), ...
Derek F's user avatar
  • 64k
1 vote
2 answers
882 views

Non-selective query against large object type error even on an indexed field

I have the dreaded Non-Selective query error but I am not sure why. I am on the Lead object and querying against 3 fields which are indexed so I am not sure why I am getting this error. I do have over ...
Phuc's user avatar
  • 373
1 vote
1 answer
471 views

Need Help Optimizing SOQL Query For 100,000+-Record Table (old query, suddenly failing)

Although my org seems to have had over 100,000 Task records for quite some time (as of this morning, we're at 119,479), between a week ago and yesterday two of the test methods that come with an ...
k..'s user avatar
  • 1,257
2 votes
3 answers
361 views

SOSL: System.QueryException: Non-selective query against large object type (more than 100000 rows)

We have over 100,000 contacts to query the system to get this error. SOSL: System.QueryException: Non-selective query against large object type (more than 100000 rows) However, this error is only ...
user1843608's user avatar
7 votes
1 answer
2k views

How do I see query plan (explain) data for a given SOQL query?

Given any SOQL query (which for the sake of this question we can assume doesn't use apex bind variables), how can I determine things like what indexes (if any) are being used, and if the query is ...
ca_peterson's user avatar
  • 23.2k
5 votes
2 answers
1k views

QueryException: Non-selective query against large object type for custom object with no records

I have a custom object in a managed package that currently has no records in the customers org. Lets call it DFB__ProductUdfMap__c (namespaces etc... have been changed to protect the innocent). The ...
Daniel Ballinger's user avatar
2 votes
3 answers
873 views

Error: System.QueryException: Non-selective query

I get this error.. 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 ...
MnZ's user avatar
  • 3,256
0 votes
1 answer
698 views

How can I make my SOQL query of Contacts filtered by AccountID more selective?

I am building a trigger on the Account object to calculate various task rollups (Completed Calls, Completed Emails, Open Tasks, etc..), and I am trying to make it also account for tasks that are ...
OBerm's user avatar
  • 1,234
2 votes
1 answer
716 views

System.QueryException: Non-selective query against large object type with 0 records

I am getting the following error for a query I am running dynamically System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or ...
pbattisson's user avatar
  • 3,310
0 votes
0 answers
136 views

Is there a way to tell if custom indexes exist on an object?

I want to be able to design to use indexes and custom indexes where they exist. Is there a way to tell if custom indexes have previously been created on a field?
dacology's user avatar
  • 2,992
2 votes
2 answers
660 views

Approaching limit for non-selective query: How to find the offending query?

I am getting following warning email but can not find out where exactly the problem is. I am facing problem in finding out which SOQL query is causing issue. Any help will be much appreciated :) ...
Sara's user avatar
  • 1,175
5 votes
1 answer
745 views

Non-Selective Query Exception on Task Query

I have the following three SOQL queries in a class that is being called by a Trigger. The Trigger counts the number of completed tasks and events for a given account. List<Account> accounts = [...
stmcallister's user avatar
7 votes
1 answer
2k views

QueryException: Non-selective query (it is selective)

I am trying to query a Custom Object called Lead_Assignment__c based on some criteria. Original query below: List<Lead_Assignment__c> leadAssignments = [ SELECT Segment__c, Queue_Name__c, ...
Adrian Larson's user avatar
  • 151k
3 votes
2 answers
6k views

"Non-selective query against large object type" only occurs in trigger context despite filtering on lookups

I have a very simple after delete trigger that searches for orphan records and deletes them: List<my_ns__Orphanable_Object__c> orphans = Database.query( ' SELECT ' + ' Id ' + ' ...
Daniel Blackhall's user avatar