SF-PD2 Performance Practice Question
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?
⚠ Common exam trap
The trap here is thinking that conditional rendering or custom OFFSET queries are equivalent to true pagination, when they either still load all data or cause database inefficiency.
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
✓
Set the page size to 20 and use the StandardSetController's next() and previous() methods to navigate pages.
StandardSetController is designed for pagination in Visualforce. By setting a smaller page size, only a subset of records is rendered at a time, reducing page load and rendering time. Navigation methods handle fetching subsequent pages efficiently. This is the recommended approach for displaying large datasets in Visualforce pages without hitting view state limits.
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 an <apex:repeat> component with a rendered attribute to conditionally display only a subset of records based on a counter.
Why it's wrong here
Conditionally rendering records with a counter does not reduce the initial data retrieval or the number of records processed by the controller. All 1,000 records are still queried and held in memory, and the page still processes the entire collection, leading to slow performance. This approach does not achieve true pagination.
- ✗
Replace the StandardSetController with a custom controller that uses SOQL OFFSET to fetch records for each page.
Why it's wrong here
Using SOQL OFFSET for pagination is inefficient because the database must scan all preceding rows, which becomes slower as the offset increases. For 1,000 records, it may work, but it is not the most performant or recommended approach. StandardSetController is specifically designed to handle pagination efficiently without OFFSET.
- ✗
Enable view state and set the page's cache attribute to true to store all records in the browser cache.
Why it's wrong here
The cache attribute in Visualforce is used for caching static resources or components, not for pagination. Enabling view state does not reduce the initial load of 1,000 records; it actually increases the page size by serializing the controller state. This does not address the rendering performance issue and may worsen it.
- ✓
Set the page size to 20 and use the StandardSetController's next() and previous() methods to navigate pages.
Why this is correct
StandardSetController supports pagination through its setPageSize method and navigation methods like next() and previous(). Setting a smaller page size reduces the number of records rendered per page, improving load time. This is the intended use of StandardSetController for paginated data display in Visualforce, and it efficiently manages record retrieval.
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 →
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.