Courseiva
Performance →hardMultiple Select

SF-PD2 Performance Practice Question

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.)

⚠ Common exam trap

A common mix-up: candidates confuse Visualforce optimizations with Lightning-specific techniques, such as Lightning Data Service or @AuraEnabled methods, which are not applicable to Visualforce pages.

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

✓

Implement pagination using `StandardSetController` to limit the number of records displayed per page.

Implementing pagination with `StandardSetController` limits the number of records loaded and displayed, reducing view state and governor limit risks. Marking non-essential controller variables as `transient` reduces view state size, which directly improves page load time. Both strategies address the core performance issues of large data sets in Visualforce.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Use `@AuraEnabled` methods to retrieve data via Lightning Data Service instead of a Visualforce controller.

    Why it's wrong here

    `@AuraEnabled` methods are used in Aura/LWC components, not Visualforce. Lightning Data Service is for Lightning components and cannot be directly used in a Visualforce page. This option is not applicable to the Visualforce scenario and would not improve performance.

  • ✗

    Move the SOQL query to a future method to run asynchronously.

    Why it's wrong here

    Future methods run asynchronously and cannot return data to the Visualforce page synchronously. The page needs the data to render, so moving the query to a future method would not work. Asynchronous processing is not suitable for immediate page rendering.

  • ✓

    Implement pagination using `StandardSetController` to limit the number of records displayed per page.

    Why this is correct

    Using `StandardSetController` with pagination reduces the number of records retrieved and rendered at once, decreasing view state size and improving load time. It also helps avoid hitting governor limits by processing smaller batches. This is a standard best practice for handling large data sets in Visualforce.

  • ✗

    Use `SOQL` with `FOR UPDATE` to lock records and prevent concurrent updates.

    Why it's wrong here

    `FOR UPDATE` locks records for the duration of the transaction, which can cause contention and does not improve performance for read operations. It is used to prevent concurrent modifications, not to optimize data retrieval. This would likely worsen performance and is not relevant to the scenario.

  • ✓

    Reduce the view state by using `transient` keyword for non-essential controller variables.

    Why this is correct

    Marking non-essential variables as `transient` excludes them from the view state, reducing its size and improving page performance. This is a common optimization for Visualforce pages that handle large data sets. It helps avoid view state limits and speeds up rendering.

About these practice questions

Courseiva writes every SF-PD2 question from scratch — 226 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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-PD2 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-PD2 exam.