SF-PD2 Process Automation, Logic, and Integration Practice Question
A developer is building a Lightning web component that needs to retrieve a large dataset from a custom object and display it in a paginated table. The component must minimize the number of server round-trips and adhere to Salesforce governor limits. Which approach should the developer use?
⚠ Common exam trap
The trap here is assuming that `OFFSET` is suitable for pagination, when it becomes inefficient for large datasets due to full table scans.
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
✓
Use an Apex controller with `@AuraEnabled(cacheable=true)` and implement keyset pagination using `WHERE` clauses on an indexed field.
Keyset pagination using `WHERE` clauses on indexed fields is the recommended approach for large datasets. It avoids the performance degradation of `OFFSET` and minimizes server round-trips by fetching only the needed records. Using `@AuraEnabled(cacheable=true)` allows caching, further reducing server calls. This method adheres to governor limits and provides efficient pagination.
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 a `@wire` adapter with `getRecord` to fetch all records at once and implement client-side pagination.
Why it's wrong here
Fetching all records at once can exceed governor limits (e.g., 50,000 records) and cause performance issues. Client-side pagination on a large dataset is inefficient and can lead to memory problems in the browser. The `getRecord` adapter is designed for single records, not lists. This approach does not minimize server round-trips effectively.
- ✗
Use the `lightning-datatable` component with the `getRecords` wire adapter to fetch data in chunks.
Why it's wrong here
The `getRecords` wire adapter is not a standard Salesforce wire adapter. The correct adapter for retrieving records is `getRecord` (singular) or `getRecords` (for a list) but it does not support pagination natively. The `lightning-datatable` component requires data to be provided; it does not fetch data itself. The developer must implement data retrieval and pagination logic.
- ✓
Use an Apex controller with `@AuraEnabled(cacheable=true)` and implement keyset pagination using `WHERE` clauses on an indexed field.
Why this is correct
Keyset pagination uses `WHERE` clauses on indexed fields to fetch the next set of records, avoiding the performance overhead of `OFFSET`. It minimizes server round-trips by fetching only the required records. The `cacheable=true` annotation allows client-side caching, improving performance. This approach adheres to governor limits and scales well for large datasets.
- ✗
Use an Apex controller with `@AuraEnabled(cacheable=true)` and implement pagination using `OFFSET` in SOQL queries.
Why it's wrong here
Using `OFFSET` for pagination in SOQL can lead to performance issues and governor limit violations for large datasets. `OFFSET` forces the database to scan all preceding rows, which is inefficient. Salesforce recommends using keyset pagination (using `WHERE` clauses on indexed fields) or the `getRecord` wire adapter for better performance.
About these practice questions
One of 226 original SF-PD2 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-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.