Learning progress is unavailable. Reading and direct practice remain available; completion controls are disabled.
← Back to Salesforce DevelopmentLesson 2 of 6 · 5–10 minutes including the walkthrough and reflection
Bulkification
Production input often arrives as a collection. A design must handle the full collection without multiplying database operations unnecessarily.
The concept
Collect identifiers first, fetch the needed records together, transform in memory and write a collection. Sets remove duplicate identifiers; maps support lookup. Bulkification also requires selecting only relevant records rather than loading unrelated data.
Worked example
Illustrative algorithm:
inputIds = unique identifiers from inputs
relatedRecords = fetch relevant records for inputIds once
changes = []
for record in relatedRecords:
if change is necessary: append change
write changes togetherThe loop processes values already in memory. The database reads and writes are outside the per-record loop. If two inputs reference the same related record, decide how to combine the changes before writing; a collection alone does not resolve conflicting business decisions.
Common mistake
Moving a query into a helper called inside a loop, or assuming a loop is safe simply because it uses a list.
Interview angle
Describe how the number of database operations grows with input size. Separate computational work from database operations and explain duplicate handling.
Pause and apply
Use a paper example with five inputs, including two duplicate references and one input requiring no change. Build the identifier set and the final change collection. Explain how you would test both a single record and a large collection. This exercise teaches a general pattern, not the checkpoint implementation.
Official references
Reviewed 2026-09-13. Examples are illustrative; no code is executed here.
Apply it in practice
Bulk-safe Account Trigger
Marking a lesson as read records learning activity, not mastery. Practice evidence continues to come from the challenge system.