SF-PD2 Performance Practice Question
A developer is building a search feature that must query across multiple objects. What is the most performant approach to searching for a term that might exist in any field?
⚠ Common exam trap
Candidates frequently choose SOQL with multiple OR filters across different objects, which is syntactically impossible in a single query and leads to inefficient, multiple database round-trips.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use a SOSL query to perform a multi-object search.
SOSL is optimized specifically for full-text searching across multiple objects. Unlike SOQL, which is designed for structured data retrieval and field filtering, SOSL indexes text fields to return results quickly. Using SOSL ensures that the search functionality remains performant as record volumes increase, preventing the performance degradation that would occur if multiple SOQL queries were executed sequentially to achieve the same result.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Run multiple SOQL queries and combine the results in Apex.
Why it's wrong here
Executing multiple SOQL queries is inefficient and consumes unnecessary governor limits. Each query incurs its own overhead and latency. This approach does not scale well as the number of objects increases, leading to potential timeouts and a poor user experience during the search operation.
- ✓
Use a SOSL query to perform a multi-object search.
Why this is correct
SOSL is designed for searching multiple objects simultaneously by utilizing pre-built indexes on text fields. It is significantly faster than executing individual SOQL queries, especially when the search scope spans several objects, making it the standard choice for building efficient, high-performance search features in Salesforce.
- ✗
Implement a custom Apex search using a loop over all records.
Why it's wrong here
Iterating over all records in Apex is never performant. It would require loading millions of records into memory, which would immediately exceed heap size limits. This approach is highly inefficient and would cause the application to crash long before it could return any useful search results.
- ✗
Query the Setup Audit Trail object for search results.
Why it's wrong here
The Setup Audit Trail is for tracking administrative changes to the Salesforce configuration, not for searching business data. Querying this object for record search purposes is inappropriate and would yield no relevant data, failing to solve the developer's requirement for a multi-object search feature.
About these practice questions
One of 226 original SF-PD2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-PD2 practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-PD2 exam.