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 questions
Answer options
A: SOSL is faster for text searches. Correct answer
B: SOQL is able to return more records Correct answer
C: SOQL Is faster for text searches.
D: SOSL is able to return more records.
Correct Answer:
A. SOSL is faster for text searches.; B. SOQL is able to return more records
Explanation

When 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.

Why Incorrect

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.

References

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.

Scroll to Top