PDI practice question 8 of 30
Universal Containers hires a developer to build a custom search page to help users find the Accounts they want. Users will be able to search on Name, Description, and a custom comments field. Which consideration should the developer be aware of when deciding between SOQL and SOSL? Choose 2 answers
Full set: 201 questionsWhen building a text-based search feature, two primary considerations are performance and the volume of data returned. SOSL is specifically designed and optimized for full-text searches across multiple fields and objects, leveraging a search index that makes it significantly faster than SOQL for this purpose. Conversely, SOQL has a much higher governor limit for record retrieval, capable of returning up to 50,000 records in a single transaction, whereas SOSL is limited to 2,000 records. A developer must balance the need for search performance against the potential size of the result set.
C. SOQL is generally slower for broad text searches compared to SOSL, which is specifically indexed and optimized for this purpose.
D. SOQL has a significantly higher record retrieval limit (50,000) than SOSL (2,000), not the other way around.
1. Salesforce Apex Developer Guide, "SOQL and SOSL Queries": The guide contrasts the two languages. In the section "When to Use SOSL vs. When to Use SOQL," it states, "Use SOSL when you don’t know in which object or field the data resides, and you want to find it in the most efficient way possible." This supports the performance advantage of SOSL for text searches.
2. Salesforce Apex Developer Guide, "Execution Governors and Limits": This official documentation provides the specific limits.
Under the "Per-Transaction Apex Limits" table, it lists: "Total number of records retrieved by SOQL queries" as 50,000.
It also lists: "Total number of records retrieved by a single SOSL query" as 2,000. This directly supports that SOQL can return more records.
3. Trailhead, Apex Basics & Database Module, "Write SOQL Queries" Unit: The section "SOQL or SOSL?" explicitly compares the two. It highlights that SOSL is used to "Search for a term in a string" and that SOQL is used when "You know which objects the data resides in." It also implicitly supports the record limit difference, which is a fundamental aspect of the platform's governor limits.
Keep practicing
Take the free PDI practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PDI practice questions
- Question 1What can be used to override the Account's standard Edit button for Lightning Experience?
- Question 4Universal Containers (UC) wants to lower its shipping cost while making the shipping proc…
- Question 5A developer has an integer variable called maxAttempts. The developer needs to ensure tha…
- Question 7Universal Containers wants to back up all of the data and attachments in its Salesforce o…
- Question 9As part of new feature development, a developer is asked to build a responsive applicatio…
- Question 10Universal Containers has an order system that uses an Order Number to identify an order f…
