ApexIntermediatesoslintegrationperformance
Build federated search integration from Apex using SOSL responsibly
Real World Scenario
Global search LWC calls Apex SOSL across Account, Contact, Lead, Case, and custom objects. SOSL times out at LDV with generic search terms.
Expected Answer
• SOSL for true global search; SOQL per object when object type known
• Minimum search term length before executing SOSL
• RETURNING clause limits rows per object preventing huge result sets
• EscapeSOSL on user input preventing injection
• Cache frequent searches in platform cache with short TTL
• Fallback per-object SOQL when SOSL returns error at volume
• with sharing on search service respecting user visibility
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Main difference: use case and scale. SOSL for true global search; SOQL per object when object type known. Minimum search term length before executing SOSL. Pick based on your integration pattern and team capability. SOSL at LDV needs guardrails—object-scoped search often beats global SOSL performance. Balance speed of delivery with maintainability.
Architect Perspective
SOSL at LDV needs guardrails—object-scoped search often beats global SOSL performance.