BookatlasTwo-Day MuleSoft → Salesforce Bootcamp
153 / 1048 · Module 5 — Salesforce Data Model + SOQL← prev⊞ allnext →

5.35Avoid query-per-record

Classic N+1 problem.

Bad:

For Each customer
    ↓
Salesforce Query

Input:

500 customers

produces:

500 queries

Instead:

extract external IDs
       ↓
single/batched SOQL query with IN
       ↓
map result by external ID
       ↓
process

If your interviewer wants architectural thinking, mention:

“I'd avoid an N+1 query pattern and retrieve related Salesforce state in batches where practical.”

Strong answer.