Salesforce-Platform-Developer-II Practice Test

Salesforce Spring 25 Release
202 Questions

Which two queries are selective SOQL queries and can be used for a large data set of 200,000 Account records?
(Choose 2 answers)

A. SELECT Id FROM Account WHERE Name LIKE '!-NULL

B. SELECT Id FRCM Account WHERE Name != ’ ’

C. SELECT Id FRCM Account WHEP Name IN (List of Names) AND Customer_Number_c= 'ValueA

D. SELECT Id FROM Account WHERE II IK (List of Account Ida)

C.   SELECT Id FRCM Account WHEP Name IN (List of Names) AND Customer_Number_c= 'ValueA
D.   SELECT Id FROM Account WHERE II IK (List of Account Ida)

Explanation:

To determine which SOQL queries are selective, we must understand what Salesforce means by a selective query, especially in the context of large data volumes (like 200,000+ records):

🔎 What is a Selective SOQL Query?
A selective query is one that filters records efficiently using indexed fields or a small, targeted data set, avoiding full-table scans and performance issues. Salesforce requires selective queries for operations like queries in triggers on large objects (more than 100,000 records), otherwise you'll hit non-selective query errors.

A query is usually selective if:
✔ It filters on indexed fields (like Id, Name, CreatedDate, lookup/master-detail fields, custom fields marked as External ID or Unique).
✔ The filter condition reduces the result set significantly (less than 10% for standard objects, 30% for custom).
✔ It uses selective operators: =, IN, <, >, not broad ones like !=, LIKE, etc.

✅ Correct Answers: C and D

✅ C. SELECT Id FROM Account WHERE Name IN (List of Names) AND Customer_Number__c = 'ValueA'
✔ Name is a standard indexed field.
✔ Customer_Number__c is a custom field, and if it's a Unique or External ID, it is also indexed.
✔ The use of IN with a short list (like under 100 values) is selective.
✔ The AND condition combining indexed fields makes the query selective.
✅ This is a good example of a selective query.

✅ D. SELECT Id FROM Account WHERE Id IN (List of Account Ids)
✔ Id is always indexed and highly selective.
✔ Using IN with a reasonable number of values (e.g., 100 or fewer) is very efficient.
✔ Salesforce even recommends this pattern for bulk-safe queries.
✅ This is definitely selective and scalable for large datasets.

❌ A. SELECT Id FROM Account WHERE Name LIKE '%-NULL'
➟ LIKE queries using wildcards at the beginning (e.g., %text) are not selective.
➟ This forces a full scan of all records to find matches.
➟ Even though Name is indexed, wildcards at the beginning disable the index.
❌ This is non-selective and dangerous for large data volumes.

❌ B. SELECT Id FROM Account WHERE Name != ''
➟ The != (not equal to) operator is not selective in Salesforce.
➟ It causes a full table scan, as it must check every record.
➟ Even if Name is indexed, the != operator disables index usage.
❌ This is non-selective and risky on objects with 200k+ records.

✅ Final Answer:
C and D are the only selective queries among the options provided.
They follow Salesforce best practices for large data sets and governor limits.

🔗 Reference: Salesforce Developer Guide – Selective Queries and Query Optimization

Page 1 out of 202 Pages