- Forcecode Newsletter
- Posts
- SOQL questions that keep showing up in Salesforce interviews (and how to answer them)
SOQL questions that keep showing up in Salesforce interviews (and how to answer them)
Know this before your next Salesforce technical interview
Hi ,
If you have a Salesforce interview coming up, SOQL optimization is going to come up. Not maybe. It's going to come up.
The reason is simple. It's the topic that separates people who've worked in real orgs from people who've only done Trailhead. Interviewers know that, and they use it.
Here's what they're actually testing when they ask about it.
Selectivity: If your WHERE clause isn't filtering on an indexed field, Salesforce scans the entire table. On a large org that means hitting limits fast. A strong answer here includes knowing which fields are indexed by default and why leading with one of them changes query performance.
SOQL in loops: This one comes up in almost every interview. Each loop iteration fires a new query and you only get 100 synchronous queries per transaction. The fix is collecting your IDs first and querying once with IN.
Subquery row limits: You’re limited to 20 subqueries per query. Knowing it before the interview and being able to explain the workaround is the kind of detail that makes interviewers take notice.
Diagnosing vs fixing: This is the one most people miss. Anyone can say "avoid SOQL in loops." Fewer people mention the Query Plan tool in the Developer Console and how it works. Bring that up and the conversation changes.
We wrote a full post on all of this with real code examples so you can see exactly what each pattern looks like in practice.
Good luck out there.
The Forcecode Team