SF-Data-Arch Data Modeling and Database Design Practice Question
Exhibit
System.LimitException: Too many SOQL queries: 101 Trigger context: After Update Object: OpportunityLineItem Related Object: PricebookEntry Query: SELECT Id FROM PricebookEntry WHERE Pricebook2Id = :pbId
Refer to the exhibit. The architect observes this error during bulk Opportunity updates. Which action resolves the issue while adhering to best practices?
⚠ Common exam trap
Candidates often confuse SOQL injection prevention with bulkification, failing to recognize that querying inside a loop rapidly exhausts governor limits regardless of data syntax.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Move the query outside the loop and store results in a Map.
The error indicates a SOQL query inside a loop, a common mistake in bulk operations. Moving the query outside the loop into a Map or List ensures that data is retrieved in a single call, optimizing performance and staying within governor limits. This is a crucial skill for architects to ensure that data models remain performant when processing high volumes of records in automated triggers.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the SOQL query limit by contacting Salesforce Support.
Why it's wrong here
Salesforce governor limits are hard-coded to protect multi-tenant infrastructure and cannot be increased for individual organizations. Attempting to bypass these limits instead of refactoring code is a sign of poor design. Proper data architecture focuses on efficient query patterns rather than requesting infrastructure changes that are not supported.
- ✗
Add a static variable to track if the query has been executed.
Why it's wrong here
While static variables can prevent repeated execution within a single transaction, they do not resolve the fundamental issue of inefficient query patterns. Relying on static flags often hides deeper problems with trigger design and does not scale well if the transaction complexity grows or logic is reorganized in future cycles.
- ✓
Move the query outside the loop and store results in a Map.
Why this is correct
Moving the query outside the loop is the standard pattern for bulkifying Apex code. By fetching all necessary PricebookEntry records into a Map at once, the logic can access them in constant time without re-querying the database, effectively eliminating the risk of exceeding SOQL limits during bulk data processing.
- ✗
Change the trigger to run in a 'without sharing' context.
Why it's wrong here
Changing the sharing context of an Apex trigger affects record visibility and security permissions, not governor limits. This does nothing to address the SOQL query limit issue and potentially introduces security vulnerabilities by bypassing organizational sharing rules, which is completely irrelevant to the performance error encountered by the developer.
Visual reference
About these practice questions
One of 222 original SF-Data-Arch practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Salesforce exam blueprint
This SF-Data-Arch practice question is part of Courseiva's free Salesforce certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SF-Data-Arch exam.