Courseiva

SF-PD2 · domain

Performance

The Performance domain of the Salesforce Certified Platform Developer II exam covers diagnosing and fixing governor-limit and scalability problems in Apex, SOQL, and triggers. Questions present debug logs, CPU or heap limit failures, and large-data query scenarios, asking you to identify the root cause and select the optimization that keeps transactions within Salesforce limits.

55 questions4 easy32 medium19 hard

Focused practice

Practice Performance questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Performance

Candidates must read debug logs, identify the specific governor limit being hit, and refactor code to bulkify, reduce queries, and use selective indexed SOQL. The single most important skill is eliminating per-record SOQL/DML inside loops.

Reading debug logs to pinpoint CPU, heap, and SOQL query limit violations in Apex transactions

Using selective SOQL filters, indexed fields, and query plans to avoid full-table scans on large objects

Bulkifying Apex triggers and using Trigger.newMap to avoid per-record DML and SOQL inside loops

Applying Asynchronous Apex (Queueable, Batch, Future) to offload long-running or high-volume processing

Watch out for

Common Performance exam traps

  • ▸Putting SOQL or DML inside a for loop, which quickly exhausts governor limits instead of bulkifying with collections
  • ▸Assuming all fields are indexed; custom fields need custom indexes and formula fields cannot be indexed at all
  • ▸Ignoring selective query filters, causing full-table scans and timeouts on large data volumes

Question index

All Performance questions (55)

Click any question to see the full explanation, or start a practice session above.

1

An Apex trigger is failing due to a 'System.LimitException: Too many DML statements: 151'. What is the optimal refactoring approach?

Hard
2

A developer is reviewing a custom Lightning Web Component that displays a list of 10,000 Contacts. The component uses a wire adapter to call an Apex method that returns all Contacts in a single response. Users report that the component loads very slowly and sometimes freezes. What is the most effective way to improve the component's performance?

Medium
3

A developer is building an Apex batch class that processes 2 million Account records. The start method uses the following SOQL query: [SELECT Id, Name FROM Account WHERE BillingCountry = 'US']. The query is selective because BillingCountry is indexed. However, during testing, the batch job fails with a 'First error: Apex CPU time limit exceeded' error. The developer suspects that the issue is related to the query performance. Which of the following is the most likely cause of the CPU timeout?

Medium
4

A developer is working on a Lightning Web Component that displays a list of 10,000 custom object records. The component currently uses an Apex controller method that returns all records in a single call, causing slow load times and occasional heap size limit exceptions. Which approach should the developer take to improve performance?

Hard
5

A developer is building a high-performance REST API integration. Which of the following is the most important practice for ensuring the integration handles high throughput?

Medium
6

A developer is optimizing an Apex trigger that processes a large number of records. The trigger currently performs a SOQL query inside a loop to check for duplicate records. This causes a 'Too many SOQL queries: 101' error when more than 100 records are processed. What is the best way to refactor the trigger to avoid this error?

Medium
7

A developer is optimizing a Visualforce page that displays a large table of OpportunityLineItem records. The page uses a standard controller with an extension that queries all related OpportunityLineItems for an Opportunity. The page loads slowly for Opportunities with thousands of line items. The developer wants to improve performance without changing the user interface significantly. Which approach is most effective?

Medium
8

A developer is writing a SOQL query on a custom object with 5 million records. The query filters on a custom field that is not indexed and returns a large number of records. The query is running slowly and sometimes fails with a 'Non-selective query' error. What should the developer do to improve query performance?

Medium
9

A developer is optimizing a Visualforce page that displays a list of accounts with their related contacts. The page uses a standard controller with an extension and a repeater component. The developer notices that the page is slow when there are many accounts, each with several contacts. What is the most likely cause of the performance issue?

Hard
10

A developer is optimizing a Visualforce page that displays a large dataset using a StandardSetController. The page currently loads slowly because it queries all records at once. The developer wants to implement pagination to improve performance. Which approach should be used?

Hard
11

A developer is optimizing an Apex trigger on the Opportunity object that updates related OpportunityLineItem records. The trigger currently performs a SOQL query for each OpportunityLineItem to check a field on the parent Opportunity. This causes performance degradation and governor limit errors. Which technique should the developer use to improve performance?

Medium
12

Refer to the exhibit. A developer is reviewing a debug log for a failed transaction. What is the primary performance issue identified in the log snippet?

Medium
13

A developer is writing an Apex trigger that updates a related object's records when a parent record is updated. The trigger currently performs a SOQL query for each child record to check if an update is needed. What is the most efficient way to optimize this trigger?

Easy
14

A developer needs to aggregate data from 10 million rows. Which approach is the most efficient for preventing governor limit issues?

Hard
15

A developer is building an Apex trigger that processes 200 Opportunity records on insert. The trigger needs to query all related OpportunityLineItem records to calculate a total. To avoid hitting the SOQL query limit, which approach should the developer use?

Medium
16

A developer is building an Apex batch job that processes 50,000 Account records. The batch class uses `Database.executeBatch` with a batch size of 200. After running the job, the developer notices that the job takes significantly longer than expected and sometimes fails with `UNABLE_TO_LOCK_ROW` errors on the Account object. What is the most likely cause of the performance degradation?

Medium
17

A developer is writing an Apex trigger on the Case object that updates a custom field on the Account when a Case is closed. The trigger currently performs a SOQL query to retrieve the Account for each Case in Trigger.new. The developer wants to optimize the trigger to handle bulk updates of up to 200 Cases without hitting governor limits. What is the best practice to achieve this?

Medium
18

A developer maintains an Apex class that performs a callout to an external REST service and then writes the response into Salesforce records. The callout occasionally takes longer than expected, and the developer wants to ensure the transaction can recover gracefully without leaving partial data. Which approach best addresses this?

Medium
19

Which THREE factors contribute to slow execution of SOQL queries in Salesforce?

Hard
20

A developer is building a Visualforce page that displays a custom object's related list with 5,000 child records. The controller currently performs a SOQL query inside a getter method that is called multiple times during page rendering, and users report the page takes over 30 seconds to load. The developer needs to improve performance without changing the page's functionality. Which approach should the developer take?

Hard
21

A developer is optimizing an Apex class that performs a large number of DML operations. The class currently updates records one at a time in a loop. Which two techniques should be used to improve performance? (Choose two.)

Medium
22

A developer is writing an Apex trigger on the Account object that performs a SOQL query inside a loop to retrieve related Contacts. To adhere to performance best practices and avoid governor limits, what is the most efficient pattern to implement?

Medium
23

A developer is building an Apex controller for a Visualforce page that must display a list of 2,000 Contacts for an Account. The current implementation uses a SOQL query inside a loop to fetch Contacts for each Account row, resulting in sluggish page loads and occasional governor limit errors. Which approach should the developer take to improve performance?

Medium
24

A developer is building a Lightning Web Component that displays a list of Accounts with their related Contacts. The component currently performs a separate SOQL query for each Account to retrieve its Contacts, resulting in 200 queries when 200 Accounts are displayed. The developer wants to reduce the number of queries to improve performance and avoid hitting governor limits. Which approach should be used?

Medium
25

A developer is designing a solution to calculate real-time statistics on a high-volume custom object, `Sensor_Reading__c`, which receives thousands of new records per hour. The statistics must be displayed on a Lightning Web Component (LWC) dashboard and must reflect the most recent data within 5 minutes. The developer considers using a scheduled Apex job to aggregate data every 5 minutes, but the aggregation query takes longer than 5 minutes to run. What is the most appropriate approach to meet the performance requirement?

Hard
26

A developer is building a Visualforce page that displays a table of 1,000 Contact records. The page uses a standard controller with an extension that queries all Contacts in the constructor. Users report that the page loads slowly. Which change should the developer make to improve performance?

Easy
27

A developer is optimizing an Apex batch job that processes millions of records and must stay within governor limits while finishing in a reasonable time. Which TWO techniques improve performance and scalability for this batch job? (Choose two.)

Hard
28

A developer is optimizing a Visualforce page that displays a table of 1,000 custom object records. The page uses a StandardSetController and currently loads all records at once, causing slow rendering. The developer wants to implement pagination to improve performance. Which approach should be used?

Hard
29

Refer to the exhibit. The query is performing poorly on an object with 5 million records. What is the most likely cause, and how should it be addressed?

Medium
30

A developer is writing a trigger on a custom object that processes up to 200 records at a time. The trigger currently performs a SOQL query inside a loop to retrieve related records for each record. This causes the trigger to hit governor limits. What is the best practice to refactor the trigger for performance?

Medium
31

A developer is optimizing a Visualforce page that displays a large list of Accounts with related Contacts. The page currently uses a standard controller with an <apex:pageBlockTable> and a controller extension that queries all Contacts for each Account in a loop. Users report that the page loads slowly and sometimes times out. Which technique should the developer implement to improve performance?

Hard
32

A developer has a Lightning Web Component that calls an Apex controller method returning 5,000 Account records to render in a custom table. Users report the component takes several seconds to become interactive. The developer wants to reduce the initial payload and rendering time. Which change is the most effective?

Hard
33

A developer needs to improve the performance of a report that queries millions of records across several custom objects. The architect suggests using Skinny Tables. Which TWO statements correctly describe the benefits and limitations of Skinny Tables? (Choose two.)

Medium
34

A developer is writing a batch Apex class to process 50,000 Account records. To ensure optimal performance and avoid hitting governor limits, which strategy should be implemented regarding DML operations?

Medium
35

When designing a high-performance integration, what is the best practice for handling data updates to avoid record locking issues?

Easy
36

A developer is building a Lightning Web Component that needs to display a list of 200 accounts with their annual revenue, and the component's Apex controller currently executes a SOQL query inside a loop over the accounts to fetch related opportunities. Users report slow load times. What is the most effective way to improve performance?

Medium
37

A developer has built a Lightning Web Component that calls an Apex controller method to retrieve a list of Opportunities for a given Account. The SOQL query uses an indexed field on the Opportunity object, but the query still times out for Accounts with over 100,000 related Opportunities. The developer wants to improve performance by reducing the amount of data transferred and processed. Which approach should the developer take?

Medium
38

A developer is optimizing a Visualforce page that displays a large table of Opportunity records. The page uses a StandardSetController and iterates over the records to display fields. Users report that the page loads slowly, and the developer notices that the page makes a SOQL query for each Opportunity to retrieve the Owner's Name. The developer wants to improve performance by reducing the number of queries. What is the most efficient way to achieve this?

Hard
39

A developer is troubleshooting a Lightning Web Component that calls an Apex method returning many records and notices the component re-fetches the same data every time the user navigates back to the tab. The developer wants to avoid redundant server calls for read-only data. Which change should be made?

Easy
40

A developer wants to use Platform Cache to improve the performance of a high-traffic Visualforce page that performs expensive SOQL queries and calculations. The data is specific to each user and should persist across multiple requests within the same session. Which type of cache should the developer use?

Medium
41

A developer needs to update a field on 50,000 child records based on a change in a parent Account. What is the most performant way to handle this update?

Medium
42

A developer is optimizing a Visualforce page that displays a large list of Opportunities with related OpportunityLineItems. The page currently uses a standard controller with an `<apex:pageBlockTable>` and a SOQL query in the controller that retrieves all Opportunities and their line items. The page loads slowly and sometimes hits governor limits. Which two strategies should the developer use to improve performance? (Choose two.)

Hard
43

A developer is writing an Apex trigger that should only fire when specific fields are changed. Which THREE practices help optimize the trigger's performance?

Hard
44

A developer is optimizing a complex Apex transaction that processes a large number of records. The transaction currently performs multiple SOQL queries and DML operations inside loops. Which two strategies should be used to improve performance and avoid governor limit errors? (Choose two.)

Medium
45

What is the primary benefit of using a Platform Cache for application data?

Medium
46

A developer is optimizing a Lightning Web Component that displays a list of 500 custom object records. The component uses a wire adapter to call an Apex method that returns the records. The Apex method currently queries all fields on the custom object, including several rich text fields and formula fields that are not displayed in the component. Users report that the component takes a long time to load. What should the developer do to improve the performance of the Apex method?

Hard
47

Refer to the exhibit. The Apex transaction is consistently hitting the CPU limit. What is the most likely cause and the best way to optimize the code?

Hard
48

An enterprise Salesforce application requires high-performance execution of complex SOQL queries across millions of records. Which strategy should a developer implement to ensure optimal query performance and prevent governor limit violations?

Medium
49

A developer is building a batch Apex class to process 1 million records. The class implements Database.Batchable and uses a SOQL query in the start method. During testing, the developer notices that the batch job fails with a 'First error: Exceeded maximum number of SOQL queries' error. What is the most likely cause and how can it be resolved?

Hard
50

A developer wants to minimize the impact of long-running operations on the user interface. Which design pattern should they utilize?

Medium
51

A developer is writing a query to fetch related records. Which SOQL pattern is best for avoiding unnecessary query execution and improving performance?

Medium
52

A developer is optimizing a complex SOQL query that joins multiple custom objects. The query is used in a trigger and is causing CPU time limit exceptions. The developer notices that the query is not using any indexes. What is the most likely cause?

Hard
53

A developer is building a search feature that must query across multiple objects. What is the most performant approach to searching for a term that might exist in any field?

Medium
54

A developer is building an Apex trigger on a high-volume custom object that must update a related child record whenever a parent record's Status__c changes. The trigger runs for both single-record UI edits and bulk API loads of 200 records. The developer wants to avoid a per-record SOQL query inside the trigger loop. Which approach is the most performant and scalable?

Medium
55

A developer has a requirement to update 5,000 records in a single transaction. The operation frequently hits the 'Too many DML statements' limit. What is the most efficient way to refactor the code?

Medium

Frequently asked questions

What does the Performance domain cover on the SF-PD2 exam?
Candidates must read debug logs, identify the specific governor limit being hit, and refactor code to bulkify, reduce queries, and use selective indexed SOQL. The single most important skill is eliminating per-record SOQL/DML inside loops.
How many questions are in this domain?
This page lists all 55 Performance questions in the SF-PD2 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Performance questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
salesforce-platform-developer-ii SALESFORCE-PLATFORM-DEVELOPER-II pd2 performance Practice Questions