I've read the docs for query selectivity, but I am still a little unsure as to how it will act for a single query using more than 1 filter in a series of AND statements.
From my analysis with the Query Planner I can see that 2 of the filters are very selective and are indexed, but another requires a full table scan.
Select Id From MyObject__c Where Very Selective Filter For Indexed Field And Very Selective Filter For Indexed Field And Non-Selective Filter For Non-Indexed Field
What I'm unsure about is whether the query as a whole is considered selective. My assumption about the way that it would work is that it would use the indexes to narrow down the records, and would then do a scan of that much smaller sub-set of records for the Non-Selective, Non-Indexed field.
However, from the cheatsheet:
Filter targets less than:
- Twice the index selectivity thresholds for each filter.
- The index selectivity thresholds for the intersection of the fields.
So, if the Non-Selective filter on it's own amounts to more than twice the index selectivity threshold for that SObject.
Just to confirm, does that mean that the query as a whole is unselective and therefore that indexes won't be used?